PodsForm::attributes PHP Method

attributes() public static method

Output a field's attributes
Since: 2.0
public static attributes ( $attributes, $name = null, $type = null, $options = null )
    public static function attributes($attributes, $name = null, $type = null, $options = null)
    {
        $attributes = (array) apply_filters('pods_form_ui_field_' . $type . '_attributes', $attributes, $name, $options);
        foreach ($attributes as $attribute => $value) {
            if (null === $value) {
                continue;
            }
            echo ' ' . esc_attr((string) $attribute) . '="' . esc_attr((string) $value) . '"';
        }
    }

Usage Example

<?php

$type = 'textarea';
$attributes = array();
$attributes['tabindex'] = 2;
$attributes = PodsForm::merge_attributes($attributes, $name, $form_field_type, $options);
if (pods_var('readonly', $options, false)) {
    $attributes['readonly'] = 'READONLY';
    $attributes['class'] .= ' pods-form-ui-read-only';
}
?>
    <textarea<?php 
PodsForm::attributes($attributes, $name, $form_field_type, $options);
?>
><?php 
echo esc_textarea($value);
?>
</textarea>
<?php 
PodsForm::regex($form_field_type, $options);
All Usage Examples Of PodsForm::attributes