This topic is locked

Modify Editcontrol before display

11/20/2013 3:05:55 PM
PHPRunner General questions
S
stiven author

Hello,
I was wondering if anyone knows a way to modify the editcontrol settings before the page is display. I have a a field setup as a checkbox horizontal layout. I need to add an extra input text after the checkboxes but what I'm doing isn't working. the reason why I want to modify the editcontrol and try to append the input box is because if I do it in the visual editor next to the field the input box will appear below the checkboxes, I need the input box to appear next to the checkbox in horizontal layout. Here is the code I'm using but it's not working.
The input box is appearing below the checkbox which I don't need, is there anyway to make the input box appear next to the checkboxes?.
Thanks in advance.
Attached is a screenshot of how it looks




$diag_field = $xt->fetchVar("diagnosis_editcontrol");

$diag_field .= '<INPUT id=diag style="WIDTH: 25px" maxLength=2 name=diag>';

$xt->assignbyref("diagnosis_editcontrol",$diag_field);


The reason why it shows below the checkbox is because the checkboxes are enclosed in a <div> then the div closes right after the checkboxes end. after that the input box is appended which doesn't work for me

C
cgphp 11/20/2013

You can dinamically append a new checkbox using jquery in the "Javascript onload" event. Check the append method http://api.jquery.com/append/

S
stiven author 11/20/2013

Thanks for your help, now I am having another problem :/
I'm trying to have the value entered on the input box added to the database, the value is successfully added to the field but it's not displaying on the page :/
What am I doing wrong? Here is my code, this happens on the edit page.
Before Display on edit page



$diag_field = $xt->fetchVar("diagnosis_editcontrol");

$diag_field_plus = $diag_field . ' <INPUT id=diag style="WIDTH: 20px" maxLength=2 name=diag>';

$xt->assign("diagnosis_editcontrol",$diag_field_plus);


Javascript OnLoad page



this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){

var val = $("#diag").val();

formObj.baseParams['diag'] = val;

});


Before Record Updated on edit page



$diag = $_REQUEST['diag'];

$diagnosis = $values['diagnosis'];
if($diagnosis != ""){



if($diag != ""){
$values['diagnosis'] = $diagnosis . ",". $diag;



}
}

if($diagnosis == ""){

$values['diagnosis'] = $diag;

}



This is how it looks before and after the record is saved it is the same :/ even If I add one more value on the input box. I have confirmed the value is saving correctly in the DB before save value was 6,1,2,5 then after save the value is 6,1,2,5,9 but it keeps showing the same checkboxes as checked when it is supposed to add one more checkbox which is number 9.
on the view page all values are shown correctly, including the one added through the input box... also this only happens if there are checkbox already checked and I add the value in the input box, If I add the value in the input box and there are not checkboxes checked the one I add will appear after I save.