danielbidala VIP
Total posts: 153
10 Авг 2014 15:25

I have a submission form with 30 select list all with tha same values from db. I dont't want to use the select field built in db query function because the same query will run 30 times. I built my db query inside the form's template php but I don't know how to set the values of the 30 select field.

Does sombody can help me on this?

Последние изменения: 31 Авг 2014


Sergey
Total posts: 13,748
11 Авг 2014 01:17

First you cannot set it ad ID/Value. You only set values. What you need to do, before you call ->getInput() of the field, you have to set ->params->set('params.values', $values) property.


danielbidala VIP
Total posts: 153
11 Авг 2014 16:55

I use copy of defult form template and fields are displayd by php foreach. I'm trying to do somthing like this on line 360 but with no luck:

<?php foreach ($fields as $field_id => $field):?>
                <div id="fld-<?php echo $field->id;?>" class="control-group odd<?php echo $k = 1 - $k ?> <?php echo 'field-'.$field_id; ?> <?php echo $field->fieldclass;?>">
          !!!!!line360!!!!!<?php if($field->id == 24 )           
            $field->params->set('params.values', $eszkoz_fajta);
          ?>!!!!!!!!!!!!
          <?php if($field->params->get('core.show_lable') == 1 || $field->params->get('core.show_lable') == 3):?>
                        <label id="lbl-<?php echo $field->id;?>" for="field_<?php echo $field->id;?>" class="control-label <?php echo $field->class;?>" >

My db query (with print_r () I see values):

$query = $db->getQuery(true);
$query->select('title');
$query->from($db->quoteName('#__js_res_record'));
$query->where($db->quoteName('type_id')." = 3" );
$db->setQuery($query);
$eszkoz_fajta = $db->loadColumn();

Am'I on the right way? I'm absolute beginner in php. Thanks for your effort.


Sergey
Total posts: 13,748
12 Авг 2014 02:31

danielbidala Am'I on the right way?

I would no go this way. Because titles of articles tends to be changed. And you cannot change it in all other records where it is selected.

What I did, I improved the code and made sure that the same query will be executed only once. So better use SQL source.

And in your code you have to use

$field->params->set('params.values', implode("\n", $eszkoz_fajta));

Because in parameters values is a simple text.


danielbidala VIP
Total posts: 153
12 Авг 2014 09:36

What I did, I improved the code and made sure that the same query will be executed only once. So better use SQL source.

Do you mean you modified component (new version)? And I can use built in function in select field setup to make sql query for all of 30 field without duplicated db query?


Sergey
Total posts: 13,748
12 Авг 2014 11:32

danielbidala

What I did, I improved the code and made sure that the same query will be executed only once. So better use SQL source.

Do you mean you modified component (new version)? And I can use built in function in select field setup to make sql query for all of 30 field without duplicated db query?

Yes.

But you have to wait new release on Thursday.


danielbidala VIP
Total posts: 153
12 Авг 2014 12:31

Oh, Man! You and Cobalt are the Number1! Do you know how many times I had wasted with Crosstec's Content Builder for my recent project before I gave a try for Cobalt. Cobalt must be more well known in Joomla community need a bit more marketing! Thanks for your efforts!


Sergey
Total posts: 13,748
12 Авг 2014 22:48

Thank you. Your review on JED will be much appreciated.


danielbidala VIP
Total posts: 153
30 Авг 2014 10:16

Sergey Thank you. Your review on JED will be much appreciated.

It's done, I added review on JED!

I didn't see this modification on Changelog. Is it added?


Sergey
Total posts: 13,748
31 Авг 2014 22:32

I do not put all changes in the log. Some of them I forget to comment when commit chnages, some are not important to mention. In your case that was buzy day, I made a lot of changes and then forget to kog this change. But it is there. YOu can check with debug mode.

Работает на Cobalt