PodsForm::data PHP Method

data() public static method

Output a field's data (for use with jQuery)
Since: 2.0
public static data ( $data, $name = null, $type = null, $options = null )
    public static function data($data, $name = null, $type = null, $options = null)
    {
        $data = (array) apply_filters('pods_form_ui_field_' . $type . '_data', $data, $name, $options);
        foreach ($data as $key => $value) {
            if (null === $value) {
                continue;
            }
            $key = sanitize_title($key);
            if (is_array($value)) {
                $value = implode(',', $value);
            }
            echo ' data-' . esc_attr((string) $key) . '="' . esc_attr((string) $value) . '"';
        }
    }

Usage Example

}
// Remove weight as we're going to allow reordering here
unset($field['weight']);
// Remove options, we don't need it in the JSON
unset($field['options']);
unset($field['table_info']);
$data = array('row' => $pods_i);
?>
<tr id="row-<?php 
echo $pods_i;
?>
" class="pods-manage-row pods-field-init pods-field-<?php 
echo esc_attr(pods_var('name', $field)) . ('--1' === $pods_i ? ' flexible-row' : ' pods-submittable-fields');
?>
" valign="top"<?php 
PodsForm::data($data);
?>
>
    <th scope="row" class="check-field pods-manage-sort">
        <img src="<?php 
echo PODS_URL;
?>
ui/images/handle.gif" alt="<?php 
esc_attr_e('Move', 'pods');
?>
" />
    </th>
    <td class="pods-manage-row-label">
        <strong> <a class="pods-manage-row-edit row-label" title="<?php 
esc_attr_e('Edit this field', 'pods');
?>