Jump to content

Edit a Value List via web PHP API (not using values from field)


This topic is 3007 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I would like to edit a value list via a web interface- I have done this using a field ("Use values from field"), but that [I incorrectly assumed, see doughemi's suggestion below!] requires adding/editing a record for each value, while (if possible) the textarea box would allow the editing of the whole value list at once.

Genx showed how to display a value list...

$layout = $fm->getLayout('my_template');

$list = array_map("htmlentities",(array)$layout->getValueList('my_list'));

I am hoping there is some easy way to send back an edited valuelist…  We are using Filemaker Server 11 (not advanced).

Thanks in advance!

Edited by Dave Carmean
Link to comment
Share on other sites

Your values do not necessarily need to be in separate records.  You can use a field in one record with a return-delimited list of values to create a value list.

I use a one-record utility table for things like this.  Your php code would look something like this:

$layout = $fm->getLayout('YourLayout');
$list = array_map("htmlentities",(array)$layout->getValueList('YourValueList'));
$newlist = $list;
//
//modify your $newlist array here
//
//convert the array to a return-delimited string
$newString = implode("\n",$newlist );
// now upload it to the database in a field named "vlfield" in utility table named "yourUtilityTable"
$getstuff = $fm->newFindAllCommand('yourUtilityTable');
$result = $getstuff->execute();
$records = $result->getRecords();
$myRecord = $records[0];
$myRecID = $myRecord->getRecordId();
$sendNewVL = $fm->newEditCommand('yourUtilityTable', $myRecID);
$sendNewVL -> setField('vlfield', $newString);
$result2 = $sendNewVL->execute();
//return-delimited list is now in vlfield.  Use the values from vlfield to create your value list.

 

  • Like 1
Link to comment
Share on other sites

This topic is 3007 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.