Hi,
I have a script on the same server as Joomla and Chronoforms.
It's part of a seat booking script and it returns available tickets for a conference, such that if you were to echo out the output, it would look like this...
Is it possible to use this data to populate a select box?
I have tried using custom code and 'including' the file but I'm clearly missing something.
Many thanks.🙂
d.
I have a script on the same server as Joomla and Chronoforms.
It's part of a seat booking script and it returns available tickets for a conference, such that if you were to echo out the output, it would look like this...
A1=A1
A2=A2
A3=A3
A4=A4
A5=A5
Is it possible to use this data to populate a select box?
I have tried using custom code and 'including' the file but I'm clearly missing something.
Many thanks.🙂
d.
Hi driv,
It's probably possible, do you have any control over the format output?
If you can build an array in the form
Bob
It's probably possible, do you have any control over the format output?
If you can build an array in the form
$form->data['tickets'] = array(
[0] => array( 'value' => 'A1', 'text' => 'A1' ),
[1] => array( 'value' => 'A2', 'text' => 'A2' ),
. . .
);
then you can use the Dynamic Data settings in the select drop-down element.
Bob
Hi Bob,
I could probably include it in another file and manipulate the output that way.
But what I don't understand is how to get the output of the script into this bit:
It's probably obvious to programmers (but I'm not one).
In an easy ideal world I would add this to custom code...
(But I'm quite sure that doesn't work.)
If this is outside the scope of help here, I'm happy to pay for assistance.🙂
Thanks.
I could probably include it in another file and manipulate the output that way.
But what I don't understand is how to get the output of the script into this bit:
$form->data['tickets'] =
It's probably obvious to programmers (but I'm not one).
In an easy ideal world I would add this to custom code...
$form->data['tickets'] = "path/to/available.php"
(But I'm quite sure that doesn't work.)
If this is outside the scope of help here, I'm happy to pay for assistance.🙂
Thanks.
Still struggling with this...
Would you mind confirming that this is the correct format for my array, please?
(This is via print_r() )
Thanks.
Would you mind confirming that this is the correct format for my array, please?
(This is via print_r() )
Array ( [0] => Array ( [value] => A1 [text] => A1 ) [1] => Array ( [value] => A2 [text] => A2 ) [2] => Array ( [value] => A3 [text] => A3 ) [3] => Array ( [value] => A4 [text] => A4 ) [4] => Array ( [value] => A5 [text] => A5 ) [5] => Array ( [value] => A6 [text] => A6 ) [6] => Array ( [value] => A7 [text] => A7 ) [7] => Array ( [value] => A8 [text] => A8 ) [8] => Array ( [value] => A9 [text] => A9 ) [9] => Array ( [value] => [text] => ) [10] => Array ( [value] => A11 [text] => A11 ))
Thanks.
Hi driv,
No I don't think that is a valid array - please see the example I posted earlier.
Bob
No I don't think that is a valid array - please see the example I posted earlier.
Bob
I do apologise for my ignorance here, but is this array actually an array like..
or a string like...
I'm sorry, I really am trying hard here.😟
$free = array();
for($i=0; $i < count($available_tables); $i++)
$free[] = ['value' => $available_tables[$i], 'text' => $available_tables[$i]];
or a string like...
$free = "array(";
for($i=0; $i < count($available_tables); $i++) {
$free.= "[$i] => array('value' => '$available_tables[$i]', 'text' => '$available_tables[$i]')";
if ($i != $max-1) {
$free.= ", ";
}
else {
$free.= ");";
}
}
$form->data['req_table1'] = $free;
I'm sorry, I really am trying hard here.😟
Hi driv,
It's an array - actually an array of arrays. Please try
Bob
It's an array - actually an array of arrays. Please try
$free = array();
foreach ( $available_tables as $k => $v )
$free[] = array( 'value' => $v, 'text' => $v );
}
Bob
Hi Bob, Thanks for that.
However it seems that the output (using print_r)is identical to the example I gave earlier.
So assuming this is correct. I have a mistake elsewhere, I suppose.
Following the code snippet you provided, should I then use this line of code as per the faq example?
Other than that, the problem must lie in the dynamic data area of the select box.
However it seems that the output (using print_r)is identical to the example I gave earlier.
Array ( [0] => Array ( [value] => A1 [text] => A1 ) [1] => Array ( [value] => A2 [text] => A2 ) [2] => Array ( [value] => A3 [text] => A3 ) [3] => Array ( [value] => A4 [text] => A4 ) [4] => Array ( [value] => A5 [text] => A5 ) [5] => Array ( [value] => A6 [text] => A6 ) [6] => Array ( [value] => A7 [text] => A7 ) [7] => Array ( [value] => A8 [text] => A8 ) [8] => Array ( [value] => A9 [text] => A9 ) )
So assuming this is correct. I have a mistake elsewhere, I suppose.
Following the code snippet you provided, should I then use this line of code as per the faq example?
$form->data['req_table1'] = implode(', ', $free);
Other than that, the problem must lie in the dynamic data area of the select box.
Hi driv,
It could be that the print_r layout is dropping the commas and replacing the quotes with [] . . .
What do you see for the drop-down HTML when you link to this data in the Dynamic Data tab?
Bob
It could be that the print_r layout is dropping the commas and replacing the quotes with [] . . .
What do you see for the drop-down HTML when you link to this data in the Dynamic Data tab?
Bob
Hi Bob,
The drop down content is completely empty.
The field name for the Select box is req_table1 and that's what I have for the dynamic data - data path.
(Although I have also tried $form->data['req_table1'] and other variants.)
...and these are the values I have for value key and text key.
$form->data['req_table1'][0]['value']
$form->data['req_table1'][0]['text']
The drop down content is completely empty.
The field name for the Select box is req_table1 and that's what I have for the dynamic data - data path.
(Although I have also tried $form->data['req_table1'] and other variants.)
...and these are the values I have for value key and text key.
$form->data['req_table1'][0]['value']
$form->data['req_table1'][0]['text']
Hi driv,
Sorry, I had some quotes wrong in the example :-( This version works OK
Bob
Sorry, I had some quotes wrong in the example :-( This version works OK
<?php
$form->data['req_table1'] = array(
'0' => array( 'value' => '', 'text' => 'please select' ),
'1' => array( 'value' => 'A1', 'text' => 'A1'),
'2' => array( 'value' => 'A2', 'text' => 'A2'),
'3' => array( 'value' => 'A3', 'text' => 'A3')
);
?>
Bob
Thanks again Bob,
The problem I seem to be facing is that I can't replicate your syntax unless I create a string.
This is the code I have...
I have removed this line as apparently implode only works on one dimensional arrays.
(If I try to use it, the output of my array is... array, array, array, array etc.)
This is what the output of the array looks like...
Data path = req_table1
Value key = $form->data['req_table1'][0][value]
Text key = $form->data['req_table1'][0][text]
The problem I seem to be facing is that I can't replicate your syntax unless I create a string.
This is the code I have...
$free = array("0" => array ("value" => "", "text" =>"please select"));
foreach ( $available_tables as $k => $v ) {
$free[] = array( 'value' => $v, 'text' => $v );
}
$form->data['req_table1'] = $free;
I have removed this line as apparently implode only works on one dimensional arrays.
(If I try to use it, the output of my array is... array, array, array, array etc.)
$form->data['req_table1'] = implode(', ', $free);
This is what the output of the array looks like...
Array
(
[0] => Array
(
[value] =>
[text] => please select
)
[1] => Array
(
[value] => A1
[text] => A1
)
[2] => Array
(
[value] => A2
[text] => A2
)
[3] => Array
(
[value] => A3
[text] => A3
)
)
Data path = req_table1
Value key = $form->data['req_table1'][0][value]
Text key = $form->data['req_table1'][0][text]
Hi driv,
You don't want to implode it so missing that out is good.
Please change the Value and Text keys to just value and text with no quotes or brackets.
Bob
You don't want to implode it so missing that out is good.
Please change the Value and Text keys to just value and text with no quotes or brackets.
Bob
Hi Bob,
Thanks for that suggestion, but unfortunately it didn't have any effect.
d.
Thanks for that suggestion, but unfortunately it didn't have any effect.
d.
Hi driv,
By all means PM me the site URL, the form name, and a SuperAdmin login and I'll take a quick look. Can I see your custom code from the Forms Manager?
Bob
By all means PM me the site URL, the form name, and a SuperAdmin login and I'll take a quick look. Can I see your custom code from the Forms Manager?
Bob
This topic is locked and no more replies can be posted.