public function create_field($field_name, $field_options, SiteOrigin_Widget $for_widget, $for_repeater = array(), $is_template = false) { $element_id = $for_widget->so_get_field_id($field_name, $for_repeater, $is_template); $element_name = $for_widget->so_get_field_name($field_name, $for_repeater); $field_class = $this->get_field_class_name($field_options['type']); if ($this->is_container_type($field_options['type'])) { return new $field_class($field_name, $element_id, $element_name, $field_options, $for_widget, $for_repeater); } else { return new $field_class($field_name, $element_id, $element_name, $field_options); } }
public function create_field($field_name, $field_options, SiteOrigin_Widget $for_widget, $for_repeater = array(), $is_template = false) { $element_id = $for_widget->so_get_field_id($field_name, $for_repeater, $is_template); $element_name = $for_widget->so_get_field_name($field_name, $for_repeater); if (empty($field_options['type'])) { $field_options['type'] = 'text'; $field_options['label'] = __('This field does not have a type. Please specify a type for it to be rendered correctly.', 'so-widgets-bundle'); } $field_class = $this->get_field_class_name($field_options['type']); // If we still don't have a class use the 'SiteOrigin_Widget_Field_Error' class to indicate this to the user. if (!class_exists($field_class)) { return new SiteOrigin_Widget_Field_Error('', '', '', array('type' => 'error', 'message' => 'The class \'' . $field_class . '\' could not be found. Please make sure you specified the correct field type and that the class exists.')); } return new $field_class($field_name, $element_id, $element_name, $field_options, $for_widget, $for_repeater); }
public function create_field($field_name, $field_options, SiteOrigin_Widget $for_widget, $for_repeater = array(), $is_template = false) { $element_id = $for_widget->so_get_field_id($field_name, $for_repeater, $is_template); $element_name = $for_widget->so_get_field_name($field_name, $for_repeater); if (empty($field_options['type'])) { $field_options['type'] = 'text'; $field_options['label'] = __('This field does not have a type. Please specify a type for it to be rendered correctly.', 'siteorigin-widgets'); } $field_class = $this->get_field_class_name($field_options['type']); if ($this->is_container_type($field_options['type'])) { return new $field_class($field_name, $element_id, $element_name, $field_options, $for_widget, $for_repeater); } else { return new $field_class($field_name, $element_id, $element_name, $field_options); } }