/** Returns an array of two arrays - the cleaned, suitable attributes, and * the method_vars array, which has values particular to that method * NOTE the 'component_args' key - it's an array of arrays of argument sets * for OTHER methods: $args = [$key1=>$val1,$key2=>$val2...,'component_args'=> * ['injectTpl'=>$argsx,'mkCreateBtn'=>$argsy,... ]]; * The component_args array is returned to the calling method, which decides * what to extract & provide the components IT calls. */ public function clean_opts($args, $defaults, $show = false) { if ($args && is_stringish($args)) { $args = ['content' => $args]; } if (!$args || !is_array($args)) { $params = $defaults; } else { unset($args['requiredClasses']); $params = array_merge($defaults, $args); } $attributes = keyVal('attributes', $params, []); $attributes['class'] = keyVal('class', $params) . ' ' . keyVal('requiredClasses', $params) . ' ' . keyVal('add-class', $params) . ' ' . keyVal('class', $attributes); $rawpre = keyVal('raw', $params) ? 'raw' : ''; $method_vars = ['ps_tpl' => keyVal('ps_tpl', $params), 'ps_key' => keyVal('ps_key', $params, 'content'), 'tag' => $rawpre . keyVal('tag', $params, 'div'), 'raw' => keyVal('raw', $params), 'content' => keyVal('content', $params), 'component_args' => keyVal('component_args', $params)]; return ['method_vars' => $method_vars, 'attributes' => $attributes, 'params' => $params]; }
/** Don't just default to 'tagged', cuz it's input * * @param type $name * @param type $value * @param type $options */ public function textarea($name, $value = null, $options = []) { if (!is_stringish($name) && is_arrayish($name)) { $name = keyVal('name', $name); $value = keyVal('value', $name, $value); $options = keyVal('options', $name, $options); } $options = $this->cleanAttributes($options); #If value exists in options, override arg $value = keyVal('value', $options, $value); #Set name in options $options['name'] = keyVal('name', $options, $name); //$this[] = PkForm::textarea($name, $value, $options); return $this->rawcontent(PkForm::textarea($name, $value, $options)); }
public function __toString() { if (is_stringish($this->hidden_key)) { $this->hidden($this->hidden_key); if (!in_array($this->hidden_key, $this->tpl_fields, 1)) { $this->tpl_fields[] = $this->hidden_key; } } $this->subform_data = eloquentToArray($this->subform_data); //$subform_data = eloquentToArray($this->subform_data); //return 'Hello'; //$this->subform_data = []; /* if (is_array_assoc($this->tpl_fields)) { if (!$this->label_array) { $this->label_array = array_values($this->tpl_fields); } $this->tpl_fields = array_keys($this->tpl_fields); } * */ // $tpl_fields=null; #The Template Field Names to use - either the keys or vals //public $label_array=null; #The Optional label array. $baseSubForm = parent::__toString(); $out = new PkHtmlRenderer(); $out[] = "\n"; $cnt = 0; if (is_arrayish($this->subform_data)) { $cnt = count($this->subform_data); } $out->div(RENDEROPEN, $this->templatables_attributes); if ($this->form_header) { $out[] = $this->form_header; } if (is_arrayish($this->subform_data)) { foreach ($this->subform_data as $idx => $row) { $out[] = $this->makeSubformPart($baseSubForm, $idx, $row); } } $create_button_attributes = $this->create_button_attributes; $create_button_tag = $this->create_button_tag; $create_button_wrap_tag = $this->create_button_wrap_tag; $create_button_attributes['data-itemcount'] = $cnt; //$createbutton = $this->div($this->create_button_label, $this->create_button_attributes); $out->{$create_button_wrap_tag}(RENDEROPEN, $this->create_button_wrap_attributes); $out->{$create_button_tag}($this->create_button_label, $create_button_attributes); $out->RENDERCLOSE(); //$out[] = $this->div($this->create_button_label, $create_button_attributes); /* $out[] = $this->$create_button_tag($this->create_button_label, $this->create_button_attributes); */ $out[] = "\n"; $out[] = $this->makeSubformPart($baseSubForm); $out->RENDERCLOSE(); $out[] = "\n"; //PkForm::setNamePrefix($newNamePrefix); return $out->__toString(); }
function is_scalarish($value, $nullorfalse = true) { return is_stringish($value, $nullorfalse); }