Hi Bob,
This is, I suspect, is a failing in my knowledge of PHP. But maybe not.
I want to dynamically populate a radio button from code rather than from a db read. I have been trying code like this
Where getInfoPickRenew returns a couple of names. So what I am trying to do is to define a model 'mdlCouple' and then insert two records into that model
M, Nick Ogbourne
P, Wendy Ogbourne
So in the end the model should look like
mdlCouple,M,Nick Ogbourne
mdlCouple,P,Wendy Ogbourne
and then use that in a radio button so
[attachment=0]4Bob00.png[/attachment]
Does that make sense? It is a PHP rather than a Chronoforms problem, isn't it?
Regards
Nick
This is, I suspect, is a failing in my knowledge of PHP. But maybe not.
I want to dynamically populate a radio button from code rather than from a db read. I have been trying code like this
<?php
$buttonInfo=getInfoPickRenew();
$form->data['mdlCouple']['pickWhich']['who']=$buttonInfo['M'];
$form->data['mdlCouple']['pickWhich']['who']=$buttonInfo['P'];
dump ($form->data);
?>
Where getInfoPickRenew returns a couple of names. So what I am trying to do is to define a model 'mdlCouple' and then insert two records into that model
M, Nick Ogbourne
P, Wendy Ogbourne
So in the end the model should look like
mdlCouple,M,Nick Ogbourne
mdlCouple,P,Wendy Ogbourne
and then use that in a radio button so
[attachment=0]4Bob00.png[/attachment]
Does that make sense? It is a PHP rather than a Chronoforms problem, isn't it?
Regards
Nick
Hi Nick,
I'm not completely sure how your code here works. To use the Dynamic Data option you need an array of arrays like this:
Bob
I'm not completely sure how your code here works. To use the Dynamic Data option you need an array of arrays like this:
$form->data[ModelId][0][text]
$form->data[ModelId][0][value]
$form->data[ModelId][1][text]
$form->data[ModelId][1][value]
. . .
$form->data[ModelId][99][text]
$form->data[ModelId][99][value]
So I think that your code would need to be more like:<?php
$form->data['mdlCouple'][0]['pickWhich'] = 'M';
$form->data['mdlCouple'][0]['who'] = $buttonInfo['M'];
$form->data['mdlCouple'][0]['pickWhich'] = 'P';
$form->data['mdlCouple'][0]['who'] = $buttonInfo['P'];
. . .
?>
Bob
I think that is it Bob. It is the -> that I haven't got my head around as yet.
Once again - thanks.
Once again - thanks.
Hi Nick,
The -> indicates an object rather than an array. Objects are similar to arrays but more flexible - they can contain arrays and other objects as well as strings and numbers. In general I find them more useful and flexible than arrays.
The notation is also used for Classes which are like Objects that can also have methods (i.e. functions built into them.)
Bob
The -> indicates an object rather than an array. Objects are similar to arrays but more flexible - they can contain arrays and other objects as well as strings and numbers. In general I find them more useful and flexible than arrays.
The notation is also used for Classes which are like Objects that can also have methods (i.e. functions built into them.)
Bob
This topic is locked and no more replies can be posted.