/** * Add a child component * * @param WP_Form_Component $element * @param string $key A unique key for the component. * Any existing component with the same key * will be overwritten. If $key is empty, * an attempt will be made to generate a * unique key. * @throws InvalidArgumentException * @return $this */ public function add_element(WP_Form_Component $element, $key = '') { if (empty($key)) { $key = $element->get_name(); } if (empty($key)) { throw new InvalidArgumentException(__('Cannot add nameless element to a fieldset', 'wp-forms')); } $this->elements[$key] = $element; return $this; }
protected function prepare_form_values(WP_Form_Component $component) { if ($component instanceof WP_Form_Aggregate) { foreach ($component->get_children() as $child) { $this->prepare_form_values($child); } } elseif ($component instanceof WP_Form_Element) { $value = $this->get_value($component->get_name()); $component->set_value($value); } }