Skip to content

Commit

Permalink
Changed references from fields to field_list to avoid name conflict w…
Browse files Browse the repository at this point in the history
…ith Model's fields property
  • Loading branch information
jbroadway committed Nov 22, 2011
1 parent 3a4311b commit ac3d0ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions handlers/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
return;
}

info ($f->fields, true);

if ($f->submit ()) {
// handle form submission

Expand Down Expand Up @@ -101,7 +99,7 @@
$o->failed = $f->failed;
echo $tpl->render ('form/head', $o);

foreach ($f->fields as $field) {
foreach ($f->field_list as $field) {
echo $tpl->render ('form/field/' . $field->type, $field);
}

Expand Down
8 changes: 4 additions & 4 deletions models/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Form extends \Model {
*/
public function labels () {
$labels = array ();
foreach ($this->fields as $field) {
foreach ($this->field_list as $field) {
$labels[$field->id] = $field->label;
}
return $labels;
Expand All @@ -48,7 +48,7 @@ public function labels () {
*/
public function rules () {
$rules = array ();
foreach ($this->fields as $field) {
foreach ($this->field_list as $field) {
$rules[$field->id] = (array) $field->rules;
}
return $rules;
Expand Down Expand Up @@ -78,7 +78,7 @@ public function merge_values ($obj) {
* Dynamic getter that unserializes fields and actions.
*/
public function __get ($key) {
if ($key == 'fields') {
if ($key == 'field_list') {
if ($this->_fields === false) {
$this->_fields = json_decode ($this->data['fields']);
}
Expand All @@ -96,7 +96,7 @@ public function __get ($key) {
* Dynamic setter that serializes fields and actions.
*/
public function __set ($key, $val) {
if ($key == 'fields') {
if ($key == 'field_list') {
$this->_fields = $val;
$this->data[$key] = json_encode ($val);
return;
Expand Down

0 comments on commit ac3d0ec

Please sign in to comment.