public function __construct($label, $name, array $properties = null) { $options = array("1" => "Yes", "0" => "No"); if (!is_array($properties)) { $properties = array("inline" => 1); } elseif (!array_key_exists("inline", $properties)) { $properties["inline"] = 1; } parent::__construct($label, $name, $options, $properties); }
function buddyforms_form_element_multiple($form_fields, $args) { global $post; extract($args); ob_start(); echo '<div class="element_field">'; echo ' <table class="wp-list-table widefat fixed posts"> <thead> <tr> <th><span style="padding-left: 10px;">Label</span></th> <th><span style="padding-left: 10px;">Value</span></th> <th><span style="padding-left: 10px;">Default</span></th> <th class="manage-column column-author"><span style="padding-left: 10px;">Action</span></th> </tr> </thead> </table> <br> '; echo '<ul id="field_' . $field_id . '" class="element_field_sortable">'; if (!isset($buddyform['form_fields'][$field_id]['options']) && isset($buddyform['form_fields'][$field_id]['value'])) { foreach ($buddyform['form_fields'][$field_id]['value'] as $key => $value) { $buddyform['form_fields'][$field_id]['options'][$key]['label'] = $value; $buddyform['form_fields'][$field_id]['options'][$key]['value'] = $value; } } if (isset($buddyform['form_fields'][$field_id]['options'])) { $count = 1; foreach ($buddyform['form_fields'][$field_id]['options'] as $key => $option) { echo '<li class="field_item field_item_' . $field_id . '_' . $count . '">'; echo '<table class="wp-list-table widefat fixed posts"><tbody><tr><td>'; $form_element = new Element_Textbox('', "buddyforms_options[form_fields][" . $field_id . "][options][" . $key . "][label]", array('value' => $option['label'])); $form_element->render(); echo '</td><td>'; $form_element = new Element_Textbox('', "buddyforms_options[form_fields][" . $field_id . "][options][" . $key . "][value]", array('value' => $option['value'])); $form_element->render(); echo '</td><td>'; $form_element = new Element_Radio('', "buddyforms_options[form_fields][" . $field_id . "][default]", array($option['value']), array('value' => $buddyform['form_fields'][$field_id]['default'])); $form_element->render(); echo '</td><td class="manage-column column-author">'; echo '<a href="#" id="' . $field_id . '_' . $count . '" class="bf_delete_input" title="delete me">Delete</a>'; echo '</td></tr></li></tbody></table>'; $count++; } } echo ' </ul> </div> <a href="' . $field_id . '" class="button bf_add_input">+</a>'; $tmp = ob_get_clean(); return $tmp; }