#573 Add fields as multiple box and drop down number list

open
nobody
None
1
2014-09-03
2014-07-30
Apostolos
No

Hello everybody,

I'm new at this, so please excuse any mistakes.

I have added two fields into the "entry" table ( "repeat" as well ) but I want to treat them as multiple selection and drop down list and not as text area or check boxes?

What I want to do is to give the user the possibility to select the people that will attend the meeting from a multiple selection box ( in order to avoid typos ) and insert the total number of the persons attending from a number list ( 1-100 ). The two fields won't have the same amount of people. Furthermore, the first one will add to the respective field all the names selected as one string.

Is that possible with the existing capabilities? If not, is edit_entry.php & edit_entry_handler.php the only files that I would have to change ( e.g. add a function ) in order to make this work?

I'm using mrbs-1.4.11 on Windows 7 64bit with XAMPP.

Thank you.

Discussion

  • You can turn them into drop-down lists by using $select_options in your config file. See the comments in systemdefaults.inc.php for more details. To stop them being textareas you may also have to make sure that the field in your database is a varchar whose length is less than $text_input_max characters. The default is 70, but you can change this in the config file.

    Unfortunately custom fields and $select_options do not multiple selections. However the support is there in the functions in functions.inc which generate the form fields, so you could easily edit edit_entry.php to do what you want.

    For the number of people you could use $select_options, but another way of doing it which is slightly more elegant but involves a little bit of code editing is to make your field in the database an int rather than a varchar and then MRBS will make use of of the the HTML5 type="number" form input. However you will need to edit create_field_entry_custom_field() in edit_entry.php to add in the min and max attributes for your field. This method then takes advantage of browsers' support for the number input - though of course if your users are using older browsers then they'll just get a text input field.

     
  • Apostolos
    Apostolos
    2014-07-30

    Dear Campbell,

    thank you for the information.

    Will work on that.

     
  • Retroperra
    Retroperra
    2014-09-03

    It works fine!

    I added a entry field called 'group_id' which I later want to be displayed in the day overview.

    In config.inc.php I added
    $select_options['entry.group_id'] = array('Info 14', 'Info 13', 'Info 12', 'GDK 14', 'GDK 13', 'GDK 12');

    And the field group_id turns into a drop meny.
    Next thing is to get a "display name" for the field group_id that changes with the three languages we have.

    I triued adding:
    $vocab["group_id"] = "Grupp";
    to the swedish lang file but mrbs did respond to that

     
    Last edit: Retroperra 2014-09-03


Anonymous


Cancel   Add attachments