1

I've added MX Select Plus CE in a Matrix row. The objective is when the user is digitizing inside the select options, appears "on the fly" the "title" of theses entries of a specific channel.

I chose a SQL query:

SELECT title FROM exp_channel_titles WHERE channel_id = '2'

Inside these {exp:query} fields, appears all the titles of the entries.

{exp:query sql="SELECT title FROM exp_channel_titles WHERE channel_id = '2'"}
          {title}
{/exp:query}

So inside the MX Select Plus CE - DB REQUEST field, I inserted the SQL Query:

SELECT title FROM exp_channel_titles WHERE channel_id = '2'

But in the Channel Entries Edit page, appears error messages:

Message: Undefined index: option_name 
Message: Undefined index: option_label

Inside the DB REQUEST field, what are the parameters for option_name and option_label. Does my SQL Query is correct ?

Does someone have a simple example about to show the titles of channel or other parameters and the option_name and option_label parameters?

1
  • I'll give this a crack however can you tell us if the field works ok in the Admin CP? (i.e. can you set your channel title from the drop down when you create/edit an entry?), Are you trying to replicate this for users to enter entried via the Channel Entries form?
    – Blatant
    Jun 1, 2015 at 12:23

1 Answer 1

3

Take a look at the example on the Field display :

ex 1: SELECT action_id as option_name, method as option_label, class as optgroup FROM exp_actions ORDER BY class

You will see that the query needs to mark the fields option_label and option_value within the query, using the AS operator.

Ergo, to replicate your query I have assumed you wish to display the Entry Title, and store the Entry ID, therefor I used :

SELECT entry_id AS option_name, title AS option_label 
FROM exp_channel_titles 
WHERE channel_id = '2'

I set this up and the field worked fine on the edit/publish CP pages, however it caused another error on Save.

A PHP Error was encountered
Severity: Warning
Message: is_array() expects exactly 1 parameter, 0 given
Filename: mx_select_plus/ft.mx_select_plus.php
Line Number: 608

So I inspected this line, sure enought there seems to be a type-o here (Line 698 of ft.mx_select_plus.php:

$data = ( is_array() ) ? implode( '|', $data ) : $data;

That doesn't look right! I changed this to :

$data = ( is_array($data) ) ? implode( '|', $data ) : $data;

This makes the is_array call valid and my entry is duely saved.

I can display my selected entry too, however this too is also bugged (i'd get the ticket ready for http://www.eec.ms as the documentation if not good either!), it will only display the saved value, not the label when using a database query. Fixing this is way beyond scope however this should get you started.

In summary, I'm seeing some issues in MX Select Plus specifically when using a DB query, I don't think its the 100% finished article. Hopefully the guys over at EEC.MS (MaxLazar, where are you?? :D) will see this and have a look for you.

Otherwise you could report the is_array issue and the lack of loading/saving values/labels when using a db query here : https://github.com/MaxLazar/mx-select-plus/issues

4
  • Hi Blatant. Thanks a lot for your very useful answer. I tried your SQL Query and it's working fine (the EE doc about query is very light). Thanks too to solve the PHP error problems.
    – Stéphane
    Jun 1, 2015 at 16:58
  • 1
    Very happy to help :) however you should poke the guys that build it (assuming Max doesn't see this) as it does seem to be holding some errors in this 3rd party fieldtype!
    – Blatant
    Jun 1, 2015 at 17:34
  • I will write to to Max about this. Before, MX Select was a commercial add-on, that i bought.
    – Stéphane
    Jun 1, 2015 at 22:34
  • Blatant. Thanks for this post. Very Helpful. Oct 10, 2015 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.