maximebf / atomik

Micro framework for PHP 5.3+ [UNMAINTAINED]
MIT License
46 stars 18 forks source link

Radio type input in FormHelper #42

Closed freezed closed 6 years ago

freezed commented 9 years ago

The radio type input is not defined in FormHelper. The input() function overwrite the value it's aivaiable in _$POST

Example: <? // code for action_file.php $catList = array('a', 'b', 'c', 'd');

$form = $this->form($this->url($this[$_GET['action']]));

foreach($catList as $key => $value) {
    $formInput[$key] = $value.':';
    $formInput[$key] .= $form->input(
        'val1',
        $value,
        'radio'
    );
}

<!-- code for view_file.phtml -->
<?= $form;

foreach($formInput as $input ) {
    echo PHP_EOL.$input;
};
?>
<hr />
A:<input name="val2" type="radio" value="A" checked="checked" />
B:<input name="val2" type="radio" value="B" />
<hr />
<?= $form->buttons(); ?>
</form>

The first run of this code behave normally: $_POST array:2 [ "val1" => "b" "val2" => "A" ]

The second run is polluted by the old value, whatever the value you select for val1 $_POST array:2 [ "val1" => "b" "val2" => "B" ]