public function add(RadioButton $button) { $button->setName($this->getName()); $button->setId($this->getId()); $this->buttons[] = $button; return $this; }
/** * dbCheckBox::dbCheckBox() * * Public constructor: create a new db RadioButton object * * @param object &$oForm: the form where the datefield is located on * @param string $sName: the name of the datefield * @param object $oDb: object of the database handler * @param string $sTable: the table to get the fields from * @param mixed $mFields: array of string with the names of the fields which data we should get * @param string $sExtraSQL: extra SQL statements * @return dbRadioButton * @access public * @author Johan Wiegel */ function dbRadioButton(&$oForm, $sName, &$oDb, $sTable, $mFields, $sExtraSQL = null, $sMask = null) { // call the constructor of the selectfield parent::RadioButton($oForm, $sName, ''); // make sure that the fields are set in an array $aFields = !is_array($mFields) ? array($mFields) : $mFields; $this->useArrayKeyAsValue(sizeof($aFields) == 2); // generate the query to retrieve the records $sQuery = 'SELECT ' . implode(', ', $aFields) . ' FROM ' . $oDb->quote($sTable) . ' ' . $sExtraSQL; // get the records and load the options //$this->_aOptions = is_array($aMergeArray) ? $aMergeArray : array(); // execute the query $sql = $oDb->query($sQuery); // query succeeded if ($sql) { while ($row = $oDb->getRecord($sql)) { if (sizeof($row) == 1) { $this->_aOptions[] = array_shift($row); } else { $this->_aOptions[array_shift($row)] = array_shift($row); } } } else { trigger_error("Error, could not retrieve records.<br '. FH_XHTML_CLOSE .'>\n" . "Error message: " . $oDb->getError() . "<br '. FH_XHTML_CLOSE .'>\n" . "Query: " . $sQuery, E_USER_WARNING); } }
protected function renderContent() { $name = $this->getAttribute('name'); $value = $this->getAttribute('value'); $flags = $this->getAttribute('flags'); $content = ''; if ($flags & \Nethgui\Renderer\WidgetFactoryInterface::FIELDSETSWITCH_CHECKBOX) { $chooser = new CheckBox($this->view); if ($this->hasAttribute('uncheckedValue')) { $chooser->setAttribute('uncheckedValue', $this->getAttribute('uncheckedValue')); } } else { $chooser = new RadioButton($this->view); } $chooser->setAttribute('name', $name)->setAttribute('value', $value)->setAttribute('flags', $flags); if ($this->hasAttribute('label')) { $chooser->setAttribute('label', $this->getAttribute('label')); } if ($this->hasAttribute('labelSource')) { $chooser->setAttribute('labelSource', $this->getAttribute('labelSource')); } $className = 'FieldsetSwitch'; if ($flags & \Nethgui\Renderer\WidgetFactoryInterface::FIELDSETSWITCH_EXPANDABLE) { $className .= ' expandable'; } if ($this->hasAttribute('class')) { $className .= ' ' . trim($this->getAttribute('class')); } $content .= $this->openTag('div', array('class' => $className)); $content .= $chooser->renderContent(); $content .= $this->openTag('fieldset', array('class' => 'FieldsetSwitchPanel')); $content .= $this->renderChildren(); $content .= $this->closeTag('fieldset'); $content .= $this->closeTag('div'); return $content; }
/** * FormHandler::radioButton() * * Create a radioButton on the form * * @param string $title: The title of the field * @param string $name: The name of the field * @param array $options: The options used for the field * @param string $validator: The validator which should be used to validate the value of the field * @param boolean $useArrayKeyAsValue: If the array key's are the values for the options in the field * @param string $extra: CSS, Javascript or other which are inserted into the HTML tag * @param string $mask: if more the 1 options are given, glue the fields together with this mask * @return void * @access public * @author Teye Heimans */ function radioButton($title, $name, $options, $validator = null, $useArrayKeyAsValue = null, $extra = null, $mask = null) { require_once FH_INCLUDE_DIR . 'fields/class.RadioButton.php'; // value has to be an array if (!is_array($options)) { trigger_error("You have to give an array as value with the radiobutton '{$name}'", E_USER_WARNING); return; } // create a new checkbox $fld = new RadioButton($this, $name, $options); if (!empty($validator)) { $fld->setValidator($validator); } if (!is_null($useArrayKeyAsValue)) { $fld->useArrayKeyAsValue($useArrayKeyAsValue); } if (!empty($extra)) { $fld->setExtra($extra); } if (!empty($mask)) { $fld->setMask($mask); } // register the field $this->_registerField($name, $fld, $title); }
/** * RadioButton constructor. * @param string $true * @param string $false */ public function __construct($true = "Yes", $false = "No") { parent::__construct([1 => $true, 0 => $false]); }
function CreateControls() { $this->AddCssClass('legacy-form'); /* @var $team Team */ /* @var $comp Competition */ $season = $this->GetDataObject(); /* @var $season Season */ require_once 'xhtml/forms/form-part.class.php'; require_once 'xhtml/forms/textbox.class.php'; require_once 'xhtml/forms/radio-button.class.php'; require_once 'xhtml/forms/checkbox.class.php'; # Show fewer options for a new season than when editing, beacause a new season gets settings copied from last year to save time $b_is_new_season = !(bool) $season->GetId(); # Add competition $comp = $season->GetCompetition(); $competition = new TextBox($this->GetNamingPrefix() . 'competition', $comp->GetId()); $competition->SetMode(TextBoxMode::Hidden()); $this->AddControl($competition); # Make current short URL available, because then it can match the suggested one and be left alone $short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $season->GetShortUrl()); $short_url->SetMode(TextBoxMode::Hidden()); $this->AddControl($short_url); # add years $start_box = new TextBox('start', is_null($season->GetStartYear()) ? Date::Year(gmdate('U')) : $season->GetStartYear(), $this->IsValidSubmit()); $start_box->AddAttribute('maxlength', 4); $start = new FormPart('Year season starts', $start_box); $this->AddControl($start); $summer = new RadioButton('summer', 'when', 'Summer season', 0); $winter = new RadioButton('winter', 'when', 'Winter season', 1); if ($season->GetEndYear() > $season->GetStartYear()) { $winter->SetChecked(true); } else { $summer->SetChecked(true); } $when = new XhtmlElement('div', $summer); $when->AddControl($winter); $when->SetCssClass('formControl'); $when_legend = new XhtmlElement('legend', 'Time of year'); $when_legend->SetCssClass('formLabel'); $when_fs = new XhtmlElement('fieldset', $when_legend); $when_fs->SetCssClass('formPart'); $when_fs->AddControl($when); $this->AddControl($when_fs); # add intro $intro_box = new TextBox('intro', $season->GetIntro(), $this->IsValidSubmit()); $intro_box->SetMode(TextBoxMode::MultiLine()); $intro = new FormPart('Introduction', $intro_box); $this->AddControl($intro); if (!$b_is_new_season) { # add types of matches if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) { foreach ($season->MatchTypes()->GetItems() as $i_type) { $this->match_types_editor->DataObjects()->Add(new IdValue($i_type, ucfirst(MatchType::Text($i_type)))); } } $this->AddControl(new FormPart('Match types', $this->match_types_editor)); # add results $result_container = new XhtmlElement('div'); $result_box = new TextBox('results', $season->GetResults(), $this->IsValidSubmit()); $result_box->SetMode(TextBoxMode::MultiLine()); $result_container->AddControl($result_box); $result = new FormPart('Results', $result_container); $result->GetLabel()->AddAttribute('for', $result_box->GetXhtmlId()); $this->AddControl($result); # Add rules table $rules = new XhtmlTable(); $rules->SetCaption('Points for each result'); $header = new XhtmlRow(array('Result', 'Points for home team', 'Points for away team')); $header->SetIsHeader(true); $rules->AddRow($header); foreach ($this->result_types as $result) { /* @var $result MatchResult */ # Shouldn't ever need to assign points to a postponed match if ($result->GetResultType() == MatchResult::POSTPONED) { continue; } # Populate result with points from season rule $season->PossibleResults()->ResetCounter(); while ($season->PossibleResults()->MoveNext()) { if ($season->PossibleResults()->GetItem()->GetResultType() == $result->GetResultType()) { $result->SetHomePoints($season->PossibleResults()->GetItem()->GetHomePoints()); $result->SetAwayPoints($season->PossibleResults()->GetItem()->GetAwayPoints()); break; } } # Create table row $home_box = new TextBox($this->GetNamingPrefix() . 'Result' . $result->GetResultType() . 'Home', $result->GetHomePoints(), $this->IsValidSubmit()); $away_box = new TextBox($this->GetNamingPrefix() . 'Result' . $result->GetResultType() . 'Away', $result->GetAwayPoints(), $this->IsValidSubmit()); $home_box->AddAttribute('class', 'pointsBox'); $away_box->AddAttribute('class', 'pointsBox'); $result_row = new XhtmlRow(array(MatchResult::Text($result->GetResultType()), $home_box, $away_box)); $rules->AddRow($result_row); } $result_container->AddControl($rules); # Add points adjustments $this->adjustments_editor->SetTeams($season->GetTeams()); if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) { $this->adjustments_editor->DataObjects()->SetItems($season->PointsAdjustments()->GetItems()); } $result_container->AddControl($this->adjustments_editor); # Show league table? $table = new CheckBox('showTable', 'Show results table', 1, $season->GetShowTable()); $this->AddControl($table); $this->AddControl(new CheckBox('runsScored', 'Include runs scored', 1, $season->GetShowTableRunsScored())); $this->AddControl(new CheckBox('runsConceded', 'Include runs conceded', 1, $season->GetShowTableRunsConceded())); # add teams if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) { $teams_in_season = array(); foreach ($season->GetTeams() as $team) { $teams_in_season[] = new TeamInSeason($team, $season, is_object($season->TeamsWithdrawnFromLeague()->GetItemByProperty('GetId', $team->GetId()))); } $this->teams_editor->DataObjects()->SetItems($teams_in_season); } $this->AddControl(new FormPart('Teams', $this->teams_editor)); } }
public function listaRadioFiltro($opcionBusqueda, $radio, $disabled) { $arrayRadio = array("0006" => "IMAGENES", "0003" => "EMERGENCIA", "0001" => "CONSULTA", "" => "TODOS"); $o_Radio = new RadioButton($arrayRadio); //$row_ochg = "buscar_filtro_sede()"; $row_ochg = "buscar_filtro_actividad()"; $radioHTML_01 = $o_Radio->getOptionsHTML($radio, $row_ochg, 'Grupo'); //$radioHTML=$row_ini.$row_filtro.$comboHTML_01.$row_fin_cb.$row_med.$row_dato.$comboHTML_02.$row_fin_cb.$row_fin; return $radioHTML_01; }
<?php /** * Main object. * @author Kikapp * @version 1.0 */ $win = new SDPanel(); $win->setCaption("Radio Button!"); $mainTable = new Table(); $mainTable->setRowsStyle("200dip;pd;pd;pd;66dip"); $actionBar = new ActionBar(); $actionBar->setClass("applicationBars"); $radio_button = new RadioButton(); $radio_button->setValues("Uruguay:1,US:2,Canada:3"); $radio_button->setAddEmptyItem(false); $radio_button->setTitle("Where are you from?"); $button = new Button(); $button->setCaption("Click me!"); $button->onTap(clickme()); $mainTable->addControl($radio_button, 1, 1); $mainTable->addControl($button, 5, 1); $win->addControl($mainTable); function clickme() { if ($radio_button->getValue() == "1") { echo "You are from Uruguay!"; } if ($radio_button->getValue() == "2") { echo "You are from US!"; }
/** * * Enter description here ... * @param string $name * @param int $value */ public function __construct($name, $value = '') { parent::__construct($name, array('Ja' => 1, 'Nee' => 0), $value); }
/** * @return \yii\db\ActiveQuery */ public function getRadioButtons() { return $this->hasMany(RadioButton::className(), ['Question_id' => 'id']); }