Example #1
0
 /**
  * @param G1_Shortcode_Attribute $attribute
  * @return G1_Form_Control
  */
 public static function create_form_control_from_attribute(G1_Shortcode_Attribute $attribute)
 {
     $attributeArgs = array('label' => $attribute->get_label(), 'name' => $attribute->get_id(), 'hint' => $attribute->get_hint(), 'help' => $attribute->get_help());
     switch ($attribute->get_form_control()) {
         case 'Choice':
             $attributeArgs['choices'] = $attribute->get_attr_by_name('choices');
             break;
         case 'Multichoice_Text':
             $attributeArgs['elements'] = $attribute->get_attr_by_name('elements');
             break;
     }
     $attributeArgs = apply_filters('g1_create_form_control_from_attribute', $attributeArgs);
     $control = self::create($attribute->get_id(), $attributeArgs, $attribute->get_form_control());
     $control->set_value($attribute->get_value());
     return $control;
 }