# Elementos de Formulario Perfex CRM

Referencia completa de todos os elementos HTML/PHP para formularios em modulos Perfex.

---

## Input Text

```php
<div class="form-group">
    <label for="name" class="control-label">
        <?php echo _l('name'); ?>
        <span class="text-danger">*</span>
    </label>
    <input type="text"
           id="name"
           name="name"
           class="form-control"
           value="<?php echo isset($item) ? html_escape($item->name) : ''; ?>"
           required>
</div>
```

## Textarea

```php
<div class="form-group">
    <label for="description" class="control-label">
        <?php echo _l('description'); ?>
    </label>
    <textarea id="description"
              name="description"
              class="form-control"
              rows="4"><?php echo isset($item) ? html_escape($item->description) : ''; ?></textarea>
</div>
```

## Select

```php
<div class="form-group">
    <label for="client_id" class="control-label">
        <?php echo _l('client'); ?>
    </label>
    <select id="client_id" name="client_id" class="selectpicker"
            data-live-search="true" data-width="100%">
        <option value=""><?php echo _l('select'); ?></option>
        <?php foreach ($clients as $client): ?>
            <option value="<?php echo $client['userid']; ?>"
                <?php echo (isset($item) && $item->client_id == $client['userid']) ? 'selected' : ''; ?>>
                <?php echo html_escape($client['company']); ?>
            </option>
        <?php endforeach; ?>
    </select>
</div>
```

## Select com AJAX (Clientes)

```php
<div class="form-group">
    <label for="clientid" class="control-label">
        <?php echo _l('client'); ?>
    </label>
    <select id="clientid" name="clientid" data-live-search="true"
            data-width="100%" class="ajax-search"
            data-none-selected-text="<?php echo _l('dropdown_non_selected_tex'); ?>">
        <?php if (isset($item) && $item->clientid): ?>
            <option value="<?php echo $item->clientid; ?>" selected>
                <?php echo html_escape(get_company_name($item->clientid)); ?>
            </option>
        <?php endif; ?>
    </select>
</div>
```

## Checkbox

```php
<div class="checkbox checkbox-primary">
    <input type="checkbox"
           id="is_active"
           name="is_active"
           value="1"
           <?php echo (isset($item) && $item->is_active == 1) ? 'checked' : ''; ?>>
    <label for="is_active"><?php echo _l('active'); ?></label>
</div>
```

## Radio

```php
<div class="form-group">
    <label class="control-label"><?php echo _l('status'); ?></label>
    <div class="radio radio-primary">
        <input type="radio" name="status" id="status_pending" value="pending"
               <?php echo (!isset($item) || $item->status == 'pending') ? 'checked' : ''; ?>>
        <label for="status_pending"><?php echo _l('pending'); ?></label>
    </div>
    <div class="radio radio-primary">
        <input type="radio" name="status" id="status_active" value="active"
               <?php echo (isset($item) && $item->status == 'active') ? 'checked' : ''; ?>>
        <label for="status_active"><?php echo _l('active'); ?></label>
    </div>
</div>
```

## Date Picker

```php
<div class="form-group">
    <label for="date" class="control-label">
        <?php echo _l('date'); ?>
    </label>
    <input type="text"
           id="date"
           name="date"
           class="form-control datepicker"
           value="<?php echo isset($item) ? _d($item->date) : _d(date('Y-m-d')); ?>"
           autocomplete="off">
</div>
```

## Date Time Picker

```php
<div class="form-group">
    <label for="datetime" class="control-label">
        <?php echo _l('date_time'); ?>
    </label>
    <input type="text"
           id="datetime"
           name="datetime"
           class="form-control datetimepicker"
           value="<?php echo isset($item) ? _dt($item->datetime) : ''; ?>"
           autocomplete="off">
</div>
```

## File Upload

```php
<?php echo form_open_multipart(admin_url('meu_modulo/upload')); ?>

<div class="form-group">
    <label for="attachment" class="control-label">
        <?php echo _l('attachment'); ?>
    </label>
    <input type="file" id="attachment" name="attachment" class="form-control">
</div>

<?php echo form_close(); ?>
```

## Hidden

```php
<input type="hidden" name="id" value="<?php echo $item->id; ?>">
```
