Multiple Text Field


(Nic Hubbard) #1

Is there a field in Matrix that I could use to add multiple text values? I need one exactly like the Metadata Multiple Text Field.

 

I know there is the text_box() function, but wondering if there is a way to print that, then have a button to click for "More" and it will show another input field. 

 

Need to be able to then get an array of the values stored in these fields. 


(Benjamin Pearson) #2

I think its called option list? It is called option list and its a core/attribute. Hope you can use it!


(Nic Hubbard) #3

It is called option list and its a core/attribute. Hope you can use it!

 

Thanks! I knew it was somewhere, just wasn't seeing it in the html_form.inc file so I just needing help in the right direction.

 

Need a little bit more help if possible to understand how it works. I am using this in creating a new Trigger Action, so I won't be using XML to create this interface.

 

I can easily print the core attribute using:

$device_token = array_get_index($settings, 'airship_device_token', '');
$option_list = new Asset_Attribute_Option_List(0, $device_token);
$option_list->setEditParam('width', 85);
$option_list->paint($prefix.'[airship_device_token]');

 

But my problem is being able to save those values and show them again after the screen is saved. I am sure I need to do this in the processInterface function, but not sure how. A few other assets I found did the following, but I can't get it to work for me when adjusting for my code:

 

 

 

$option_list = new Asset_Attribute_Option_List(0, NULL, SQ_OPTION_LIST_DELIMITER_UNIX);

// We assume namining of these constants, and that they always have white/black lists.
$message_types = Array(
‘LOG_TO_FILE’,
‘LOG_TO_DB’,
‘SEND_MAIL’,
);

foreach ($message_types as $message_type) {
// Names for both white and black list for this message type.
$w = ‘SQ_MS_’.$message_type.‘WHITE_LIST’;
$b = 'SQ_MS
’.$message_type.’_BLACK_LIST’;

// Process attribute. Value is string seperated by newlines (\n).
$option_list->process($w);
$_POST[$class][$w] = $option_list->value;

$option_list->process($b);
$_POST[$class][$b] = $option_list->value;
}

Do I need to somehow post my values like it is being done here?


(Benjamin Pearson) #4

Na, the $_POST vars are manipulated here and presumably used after, when saving an option_list you should just need:

$option_list->process($prefix);
$value = $option_list->value;

If you are talking about a trigger's processInterface(), you must make sure the values are going back into the $settings array and defining processInterface() as: processInterface(&$settings, $request_data)

 

The values are shown on the attribute by the value param passed into the constructor (which it looks like you are already doing).


(Nic Hubbard) #5

Na, the $_POST vars are manipulated here and presumably used after, when saving an option_list you should just need:

$option_list->process($prefix);
$value = $option_list->value;

If you are talking about a trigger's processInterface(), you must make sure the values are going back into the $settings array and defining processInterface() as: processInterface(&$settings, $request_data)

 

The values are shown on the attribute by the value param passed into the constructor (which it looks like you are already doing).

 

Thanks, got it working!