Hi All,
am using Chronoform v4 as (wizard), and i need to load the next record (onsubmit) i wrote the below code :
this is work fine🙂
but is there any method to load data without using the token value , i read the tutorial of loading data there is a method to load data using a curly brakets{field_name} can you tell me where should i put this brakets.
am using Chronoform v4 as (wizard), and i need to load the next record (onsubmit) i wrote the below code :
<?php
$db=&JFactory::getDBO();
$MyForm =& CFChronoForm::getInstance('test1');
$current_id = $MyForm->data['cf_id'];
$next_id=$current_id+1;
$url ='index.php?option=com_chronoforms&chronoform=test1&token='.$next_id.'';
$url = JRoute::_($url);
?>
<input type=button value="Next" onclick="location.href='<?php echo $url?>'" ></input>
this is work fine🙂
but is there any method to load data without using the token value , i read the tutorial of loading data there is a method to load data using a curly brakets{field_name} can you tell me where should i put this brakets.
Hi ammari,
You can use the curly brackets syntax in any HTML you use but not usually in PHP as the PHP is evaluated before the curly bracket values are substituted :-(
Bob
You can use the curly brackets syntax in any HTML you use but not usually in PHP as the PHP is evaluated before the curly bracket values are substituted :-(
Bob
Hi Bob,
i write in the custom code {field_name} which i drag it before the DB Loader and after the Show html and set the last option in Show html (curly brackets replacer)to YES , but it does not load any value😟
just show the {field_name} i confirmed that the name is the same as my input name😟
i write in the custom code {field_name} which i drag it before the DB Loader and after the Show html and set the last option in Show html (curly brackets replacer)to YES , but it does not load any value😟
just show the {field_name} i confirmed that the name is the same as my input name😟
Hi ammari,
Reading this again the DB Record Loader action needs to come before the Show HTML action. They are run in the sequence they appear.
DB Record Loader
v
Show HTML
Bob
Reading this again the DB Record Loader action needs to come before the Show HTML action. They are run in the sequence they appear.
DB Record Loader
v
Show HTML
Bob
but is there any method to load data without using the token value
Why ? I see you are building a link to the next record, the link is built ok and as long as you have the correct order of actions as Bob has mentioned then it should load the form fields data ok🙂
Thanks alot🙂
the form works fine;)🙂
but i need to prevent users from opeining the same record. (lock the open record ) how i can do that ???😑
i have an idea to drag a hidden field and set it to 0 if the record open it sets to 1 but can i save this change on database before click the submit button (on load) or somthing like that ????
thanks in advance🙂
the form works fine;)🙂
but i need to prevent users from opeining the same record. (lock the open record ) how i can do that ???😑
i have an idea to drag a hidden field and set it to 0 if the record open it sets to 1 but can i save this change on database before click the submit button (on load) or somthing like that ????
thanks in advance🙂
Hi ammari,
You'd need to have a 'lock' column in the database and in the ON Load event add Custom code to query the database' check if this record is locked and if it isn't then lock it. And, as you say, add a hidden input to 'unlock' the record when it is saved again.
This isn't built in to ChronoForms and you'd need to replace the DB Record Load with a Custom Code element.
Bob
You'd need to have a 'lock' column in the database and in the ON Load event add Custom code to query the database' check if this record is locked and if it isn't then lock it. And, as you say, add a hidden input to 'unlock' the record when it is saved again.
This isn't built in to ChronoForms and you'd need to replace the DB Record Load with a Custom Code element.
Bob
Thanks alot🙂
now i have a lock column in my database (set 0 value for all records)
on custom code which located on (onload event) can you tell how to check the lock column value should i write this code :
there is a hidden field with name of the lock column and the default value is 0 so onsubmit the lock set to 0 again🙂
thanks in advance🙂
now i have a lock column in my database (set 0 value for all records)
on custom code which located on (onload event) can you tell how to check the lock column value should i write this code :
$MyForm =& CFChronoForm::getInstance('My_form_name');
$lock = $MyForm-> data['lock'];// is this get the value saved on my database???
if ($lock == 0)// is this a correct statement ??
{
$lock=1;
$sql="Select col_1,col_2 from my_table_name LIMIT 1 ";
}
there is a hidden field with name of the lock column and the default value is 0 so onsubmit the lock set to 0 again🙂
thanks in advance🙂
Hi ammari,
In the On Load event you would want something like this
Bob
In the On Load event you would want something like this
<?php
if ( isset($form->data['lock']) && $form->data['lock'] ) {
$mainframe =& JFactory::getApplication();
$mainframe->redirect('form_url', 'This record is locked, please try later');
} else {
$db =& JFactory::getDBO();
$query = "
UPDATE `#__some_table`
SET `lock` = 1
WHERE `cf_id` = '{$form->data['cf_id']}' ;
";
$db->setQuery($query);
$db->query();
$form->data['lock'] = 0;
?>
Bob
thanks alot🙂
but i still have a problem😟
First :
i realize that the missing was the end ")" of the if statement but the error message still exist😟
and can you tell me how can i select the records after this check?? can i start typing my select statement inside the (else statement)???
but i still have a problem😟
First :
if( isset($form->data['lock'] && $form->data['lock'] )
//parse error, expecting `','' or `')''
i realize that the missing was the end ")" of the if statement but the error message still exist😟
and can you tell me how can i select the records after this check?? can i start typing my select statement inside the (else statement)???
Hi ammari,
Sorry, that line should be
I'd use a separate DB Record Load action to load the data.
Bob
Sorry, that line should be
if ( isset($form->data['lock']) && $form->data['lock'] ) {
I'd use a separate DB Record Load action to load the data.
Bob
Thanks Bob🙂
it works fine😉
now i can lock my record on load😉
the last thing i would asked to you, that i have now random function selection and it work fine and i can lock my record how i can combine these two codes to get my form work as i want
- select random record where lock=0
- set lock=1
- onsubmit lock=0
this is my random selection function :
how i can insert the check for the lock status inside this code , is it possible???
and am sorry for inconvenience but i am still beginner in this field🙂
it works fine😉
now i can lock my record on load😉
the last thing i would asked to you, that i have now random function selection and it work fine and i can lock my record how i can combine these two codes to get my form work as i want
- select random record where lock=0
- set lock=1
- onsubmit lock=0
this is my random selection function :
function random_row($table, $column) {
$max_sql = "SELECT max(" . $column . ")
AS max_id FROM " . $table;
$max_row = mysql_fetch_array(mysql_query($max_sql));
$random_number = mt_rand(1, $max_row['max_id']);
$random_sql = "SELECT cf_id,customer_id,customer_code,contact_num,contract_id,customer_name FROM " . $table . " WHERE " . $column . " >= " . $random_number . " ORDER BY rand() ASC LIMIT 1";
$random_row = mysql_fetch_row(mysql_query($random_sql));
if (!is_array($random_row)) {
$random_sql ="SELECT cf_id,customer_id,customer_code,contact_num,contract_id,customer_name FROM " . $table . " WHERE " . $column . " <" . $random_number . " ORDER BY rand() ASC LIMIT 1";
$random_row = mysql_fetch_row(mysql_query($random_sql));
}
return $random_row;
}
$r=random_row('jos_chronoforms_data_push_more_data', 'cf_id');
?>
how i can insert the check for the lock status inside this code , is it possible???
and am sorry for inconvenience but i am still beginner in this field🙂
Hi ammari,
Please try
Bob
Please try
WHERE " . $column . " >= " . $random_number . " AND `lock` = 0
Bob
I'd use a separate DB Record Load action to load the data
sorry bob , but can explian what did you mean ??
This topic is locked and no more replies can be posted.