From ca6ff993ce0fb71bd069b8c4a0463530d9f26e8c Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sun, 24 Aug 2014 14:26:53 +0300 Subject: [PATCH] initial data in forms --- ipf/form.php | 7 +++---- ipf/form/field.php | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ipf/form.php b/ipf/form.php index f7d9d73..fed4367 100644 --- a/ipf/form.php +++ b/ipf/form.php @@ -9,6 +9,7 @@ abstract class IPF_Form implements Iterator public $prefix = ''; public $id_fields = 'id_%s'; + public $initial = null; public $data = array(); public $cleaned_data = array(); public $errors = array(); @@ -28,6 +29,7 @@ abstract class IPF_Form implements Iterator } if ($label_suffix !== null) $this->label_suffix = $label_suffix; + $this->initial = \PFF\Arr::get($extra, 'initial', array()); $this->initFields($extra); $this->f = new IPF_Form_FieldProxy($this); } @@ -102,10 +104,7 @@ abstract class IPF_Form implements Iterator public function initial($name) { - if (isset($this->fields[$name])) { - return $this->fields[$name]->initial; - } - return ''; + return \PFF\Arr::get($this->initial, $name, null); } public function hiddenFields() diff --git a/ipf/form/field.php b/ipf/form/field.php index 422feb4..7ce32c9 100644 --- a/ipf/form/field.php +++ b/ipf/form/field.php @@ -8,7 +8,6 @@ class IPF_Form_Field public $label = ''; public $required = false; public $help_text = ''; - public $initial = ''; public $choices = null; public $hidden_widget = 'IPF_Form_Widget_HiddenInput'; -- 2.49.0