Repository navigation
Accept string-keyed options and array default_value in list-fields output #3581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
35d1ab0
72ba6cd
1fbdcdb
e7974ca
939d2b1
450bea8
8f2fe8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,6 +110,59 @@ public function test_a_field_round_trips_through_create_list_update_delete() { | |
| $this->assertArrayNotHasKey( $created['field_key'], $after, 'A deleted field should no longer be listed.' ); | ||
| } | ||
|
|
||
| /** | ||
| * Choice options keyed by option text, array defaults and a NULL default are what Formidable | ||
| * can store, so list-fields must not reject them, or one such field fails the whole form. | ||
| * | ||
| * @return void | ||
| */ | ||
| public function test_list_fields_accepts_string_keyed_options_and_array_default_values() { | ||
| $select_id = FrmField::create( | ||
| array( | ||
| 'form_id' => $this->form->id, | ||
| 'type' => 'select', | ||
| 'name' => 'Location', | ||
| 'default_value' => '', | ||
| 'options' => array( | ||
| '1' => array( | ||
| 'label' => '', | ||
| 'value' => '', | ||
| ), | ||
| 'Asheville' => array( | ||
| 'label' => 'Asheville', | ||
| 'value' => 'asheville', | ||
| ), | ||
| 'other_1' => 'Other', | ||
| ), | ||
| ) | ||
| ); | ||
| $address_id = FrmField::create( | ||
| array( | ||
| 'form_id' => $this->form->id, | ||
| 'type' => 'address', | ||
| 'name' => 'Address', | ||
| 'default_value' => array( | ||
| 'line1' => '1 Main St', | ||
| 'city' => 'Asheville', | ||
| ), | ||
| ) | ||
| ); | ||
| $text_id = FrmField::create( | ||
| array( | ||
| 'form_id' => $this->form->id, | ||
| 'type' => 'text', | ||
| 'name' => 'No default', | ||
| ) | ||
| ); | ||
|
|
||
| $listed = $this->execute( 'list-fields', array( 'form_id' => $this->form->id ) ); | ||
|
|
||
| $this->assertNotWPError( $listed, 'list-fields should validate for string-keyed options, array default values and a NULL default.' ); | ||
| $this->assertArrayHasKey( FrmField::getOne( $select_id )->field_key, $listed ); | ||
| $this->assertArrayHasKey( FrmField::getOne( $address_id )->field_key, $listed ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| $this->assertArrayHasKey( FrmField::getOne( $text_id )->field_key, $listed ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| /** | ||
| * @return void | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method you are trying to call is not defined, which can result in a fatal error.