public function testReadonlyField() { $sourceArray = array(0 => 'No', 1 => 'Yes'); $field = new OptionsetField('FeelingOk', 'are you feeling ok?', $sourceArray, 1); $field->setEmptyString('(Select one)'); $field->setValue(1); $readonlyField = $field->performReadonlyTransformation(); preg_match('/Yes/', $field->Field(), $matches); $this->assertEquals($matches[0], 'Yes'); }
public function testSetDisabledItems() { $f = new OptionsetField('Test', false, array(0 => 'Zero', 1 => 'One')); $f->setDisabledItems(array(0)); $p = new CSSContentParser($f->Field()); $item0 = $p->getBySelector('#Test_0'); $item1 = $p->getBySelector('#Test_1'); $this->assertEquals((string) $item0[0]['disabled'], 'disabled'); $this->assertEquals((string) $item1[0]['disabled'], ''); }
public function testSafelyCast() { $field1 = new OptionsetField('Options', 'Options', array(1 => 'One', 2 => 'Two & Three', 3 => DBField::create_field('HTMLText', 'Four & Five & Six'))); $fieldHTML = (string) $field1->Field(); $this->assertContains('One', $fieldHTML); $this->assertContains('Two & Three', $fieldHTML); $this->assertNotContains('Two & Three', $fieldHTML); $this->assertContains('Four & Five & Six', $fieldHTML); $this->assertNotContains('Four & Five & Six', $fieldHTML); }
/** * Standard SS method - returns the string for the Field. * Note that we include JS from this method. * @return HTML */ function Field() { $jsArray = array(); $js = ''; $jsonCompare = array(); if ($this->addresses) { foreach ($this->addresses as $address) { $js .= " EcomSelectOrderAddressField.set_data(" . $address->ID . ", " . $address->JSONData() . ");\r\n"; } } Requirements::javascript("ecommerce/javascript/EcomSelectOrderAddressField.js"); Requirements::customScript($js, "Update_" . $this->Name()); return parent::Field(); }
/** * @param array $properties * @return HTMLText */ public function Field($properties = array()) { $this->addExtraClass('prettyoptionsetfield')->setAttribute('data-prettyoptionsetconfig', Convert::array2json($this->pretty_optionset_config)); //allow for not including default styles if ($this->config()->get('require_css') == true) { Requirements::css(PRETTY_CHECKABLE_FIELD_THIRDPARTY . '/prettyCheckable-2.1.2/dist/prettyCheckable.css'); } Requirements::javascript(PRETTY_CHECKABLE_FIELD_THIRDPARTY . '/prettyCheckable-2.1.2/dist/prettyCheckable.min.js'); if (is_a($this->Form, 'BootstrapForm')) { Requirements::javascript(PRETTY_CHECKABLE_FIELD_JAVASCRIPT . 'pretty.optionset.field.bootstrap.js'); } else { Requirements::javascript(PRETTY_CHECKABLE_FIELD_JAVASCRIPT . 'pretty.optionset.field.js'); } return parent::Field($properties); }
function testFieldHasExtraClass() { /* TextField has an extra class name and is in the HTML the field returns */ $textField = new TextField('Name'); $textField->addExtraClass('thisIsMyClassNameForTheFormField'); preg_match('/thisIsMyClassNameForTheFormField/', $textField->Field(), $matches); $this->assertTrue($matches[0] == 'thisIsMyClassNameForTheFormField'); /* EmailField has an extra class name and is in the HTML the field returns */ $emailField = new EmailField('Email'); $emailField->addExtraClass('thisIsMyExtraClassForEmailField'); preg_match('/thisIsMyExtraClassForEmailField/', $emailField->Field(), $matches); $this->assertTrue($matches[0] == 'thisIsMyExtraClassForEmailField'); /* OptionsetField has an extra class name and is in the HTML the field returns */ $optionsetField = new OptionsetField('FeelingOk', 'Are you feeling ok?', array(0 => 'No', 1 => 'Yes'), '', null, '(Select one)'); $optionsetField->addExtraClass('thisIsMyExtraClassForOptionsetField'); preg_match('/thisIsMyExtraClassForOptionsetField/', $optionsetField->Field(), $matches); $this->assertTrue($matches[0] == 'thisIsMyExtraClassForOptionsetField'); }
function Field($properties = array()) { Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/SexyOptionsetField.js'); return parent::Field($properties); }
public function Field() { $this->getSource(); //die($this->Link('findOrAdd')); //Requirements::javascript(THIRDPARTY_DIR."/jquery-livequery/jquery.livequery.js"); Requirements::javascript(MOD_QA_DIR . '/javascript/quickAddField.js'); Requirements::CSS(MOD_QA_DIR . '/css/quickaddfield.css'); if ($this->fieldType == 'CheckboxSetField') { $selectAll = ''; if ($this->selectAll) { $selectAll = '<a class="selectAll" href="#">Select All</a>'; } return $selectAll . CheckboxSetField::Field(); } return parent::Field(); }
/** * @param array $properties * @return HTMLText */ public function Field($properties = array()) { Requirements::css(COLORPALETTE_DIR . '/css/ColorPaletteField.css'); return parent::Field($properties); }
/** * @param array $properties * @return HTMLText */ public function Field($properties = []) { Requirements::css(IMAGEOPTIONSETFIELD_PATH . '/css/imageoptionsetfield.css'); return parent::Field($properties); }
function Field() { OptionsetShowHideField::include_files(); return parent::Field(); }