#1
I have created a form and added radio buttons to give the user the choice of where to place the blog post in a homepage slider. There are a max of 3 slides available, so the radio button options when creating the post are ' No , 1 , 2 , 3.'
i.e. The No option is that they do not want the blog post on the home page slider . '1' means first position in slider etc.

I have all working fine, however I have noticed that when the user goes to edit (update details) the blog post, the radio options are not being read from the db and it is always showing '3', even though the db has a different value (e.g. 1, 2 or 3). Manage view is fine. Also, I can see that $data = $this->_get_data_from_db($update_id); from function create(); is returning the correct db values.

In the form in create.php , I have the following lines for the radio button., $checked = true on first line because when a user initially create a new blog post, I want 0, to be the default.
#2
Hello John,
Can you post the code that calls the db.
That would help us see what's going on when you make the call to the db.

Also your update method


Thanks,
Dan
#3
Hi,
it is the std create method,


here is the json dump and "home_page_placement": 2 is correct, but the view file t /blog_posts/create/1 highlights option 3.

#4
Hi John,

The reason it is showing '3' always checked, is the html produced for the radio buttons are true for checked


You have shared everything except the 'create.php' view file for the form. This is where you can add the following code to dynamically enable the checked radio button:


I hope that helped

Cheers,
Si

Updated:
ps - David, you should restrict the code width so it doesn't stretch so long which is making the page extremely wide
suggest you add the following to the <pre> tag
#5
Yes, that's how I read it. $home_page_repalcement is 2 (to PHP, it has a tangible value and therefore is TRUE)
#6
Thanks Si,

that worked a treat.

I am making good progress in my learning, but It is time like this when I realise just how far I have to go.

;-|