"Basic Connectivity v5 listing"
"Connectivity edit with Chronoforms"
The registries list is showing ok, the edit column works fine and recovers the data correctly to the "edit" version of my initial form, but the problem appears when I make a change to the entries and try to save the form. I become the message "Connection not found".
For the editable form I did not create any table because I thought that all the data would save in the original table of my first form, is this correct? Or do I have to create a new table for this "editable" form?
Another problem I find is with the checkbox groups:
in the new editable form I used the field names like is described in the FAQ: Article[title]. For the checkbox group I named the elements like Article[title[]], and it retrieves only one of the selected options of the checkbox group. I tried also naming the field without the square brackets Article[title] and in this case it doesn't retrieve any of the options. With is the correct form to do this?
But still unable to recover multi answers when using checkbox group, any ideas?
This is the post:
https://www.chronoengine.com/forums/posts/f3/t96921.html?page=1
The proposal is to add a custom code to explode the data in the checkbox group when loaded to the "editable" form. This custom code should be placed after a DBread action. In my case I don't have any DBread action in any of the forms (the first one for data input connected with another form for editing).
Should I place a DBread action in any of them?
In which one?
Thanks
My actual config.
[attachment=0]Captura de pantalla 2015-08-03 a las 10.58.10.png[/attachment]
[attachment=1]Captura de pantalla 2015-08-03 a las 10.58.46.png[/attachment]
[attachment=2]Captura de pantalla 2015-08-03 a las 11.01.54.png[/attachment]
I think that CC is probably doing the DB Read for you in the edit form. Please try putting the Custom Code action before the HTML (Render form) action in the On Load event and see if that works OK.
Bob
Thank you very much Bob
<?php
$form->data["checkboxes_name"] = explode(",", $form->data["checkboxes_name"]);
if my model is "regcsp" and my form name is "CRDCSP" should the code look like:
<?php
$CRDCSP->regcsp["checkboxes_name"] = explode(",", $CRDCSP->regcsp["checkboxes_name"]); ?
No; leave it unchanged except for checkboxes_name which should be replace by the name of the CheckBox Group element
Bob
http://www.chronoengine.com/component/chronoforums/posts/f12/t98786.html
If my checkboxgroup has de Field name:
ap[] (this one in the form for creating new entries, the one that has the table created)
regcsp[ap] (this is the name in the form for editing pruposes)
and the Model Title in the CC connection is: regcsp. What does it have to look like?
Code proposal in the post:
<?php
if(!empty($form->data["Model"]["checkboxes_field"])){
$form->data["Model"]["checkboxes_field"] = explode(",", $form->data["Model"]["checkboxes_field"]);
}
What I tried (other options also, but I put this one because it seems to me the more closely to be correct one, obviously isn't)
<?php
if(!empty($form->data["regcsp"]["ap[]"])){
$form->data["regcsp"]["ap[]"] = explode(",", $form->data["regcsp"]["ap[]"]);
}
Thanks
Please try
<?php
if( !empty($form->data['regcsp']['ap']) ) {
$form->data['regcsp']['ap'] = explode(',', $form->data['regcsp']['ap'] );
}
?>That is to leave out the [] after ap
Bob
<?php
if( !empty($form->data['regcsp']['ap']['fr']) ) {
$form->data['regcsp']['ap'] = explode(',', $form->data['regcsp']['ap']['fr'] );
}
?>Is this correct?
Thanks again.
That doesn't look right to me. The existing code should work - but it does depend on how you've named the checkboxes.
Bob
It should be exactly the same but with 'fr' in place of 'ap'.
Bob
Thanks.
No, you can do it all in one custom code action something like this:
<?php
$checkboxes = array(
'ap',
'fr',
'xx',
'yy',
'zz'
);
foreach ( $checkboxes as $c ) {
if( !empty($form->data['regcsp'][$c]) ) {
$form->data['regcsp'][$c] = explode(',', $form->data['regcsp'][$c] );
}
}
?>That assumes that they are all named with the regscp model id.
Bob
[[>> Later : updated to correct typo <<]]
<?php
$checkboxes = array(
'ap',
'fr'
);
foreach ( $scheckboxes as $c ) {
if( !empty($form->data['regcsp'][$c]) ) {
$form->data['regcsp'][$c] = explode(',', $form->data['regcsp'][$c] );
}
}
?>
And yes all are named with the redcaps model id.
Thank you.
Please correct my typo $scheckboxes should be $checkboxes.
Bob
