Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthortamboo
     
    Hi,
    Recently, I am working almost with Akelos Framework.

    I'm just saving null string('').
    There seems to be a difference in the save when create and update.

    When creating it, can you save the null string('')?
    Because the NULL is not contained in input tag.
    I hope,

    <input name="item[value]" type="radio" value="" />

    Item: id int, value string

    <?php

    function add(){
    $this->Item->setAttribute(array('value' => ''));
    $this->Item->save();
    }
    // value => null

    function edit(){
    $this->Item->setAttribute(array('id' => 1, 'value' => ''));
    $this->Item->save();
    }
    // value => ''

    ?>
    •  
      CommentAuthorbermi
     

    Shouldn't you be calling?

    $this->Item->setAttributes(array('value' => ''));
    

    setAttributes in plural?

    • CommentAuthortamboo
     
    I'm sorry.
    It is this description mistake.

    $this->Item->setAttributes(array('value' => ''));

    But, this result is the same.
    •  
      CommentAuthorbermi
     

    You should use helpers to create your radio inputs, as they add a hidden value before the radio for those situations when its not checked.

    • CommentAuthortamboo
     

    The selected radiobutton cannot be released. Then, I adding selection 'no select' item.

    Is it a specification that cannot add the null string(not NULL)? update is OK.

    I'm just make a ActiveFormHelper extends FormHelper. It is automatically makes the form tags and the selection items from the database.

    SelectItem Model: id int, value string, title string, category ... 1, 1, 1 minute 2, 3, 3 minute 3, 5, 5 minute 4, 10, 10 minute 5, null, no select <- I hope save null string(not NULL)

    $this->SelectItem->setAttributes(array('value'=>'', 'title'=>'no select'));
    $this->SelectItem->save();
    

    Output from SelectItem.

    class ActiveFormInstanceTag extends AkFormHelperInstanceTag
    {
        function to_select_radio_tag($select_items, $options)
        {
            $select_radio = '';
            foreach ($select_items as $value => $text){
                $select_radio .= parent::to_radio_button_tag($value, $options).
                $text.'&nbsp;&nbsp;';
            }
            return $select_radio;
        }
    }
    

    Output html.

    < html>
    <input name="search[min]" type="radio" value="1" /> 1 minute
    <input name="search[min]" type="radio" value="3" /> 3 minute
    <input name="search[min]" type="radio" value="5" /> 5 minute
    <input name="search[min]" type="radio" value="10" /> 10 minute
    <input name="search[min]" type="radio" /> No select              <- if select this.
    </html>
    

    Result:

    echo $this->params['search']['min']  =>  'on';
    
    • CommentAuthorKaste
     

    Is it a specification that cannot add the null string(not NULL)?

    I dont think so.

    -> #123

    • CommentAuthortamboo
     

    Thank you so much.