1
patagon
article 1.0 - How to create dropdown
  • 2007/6/8 3:23

  • patagon

  • Quite a regular

  • Posts: 235

  • Since: 2002/1/8 0


Hi,

I'm using article module and I would like to create a dropdown (or modify an existing field so that its a dropdown). Now, I dont have to populate this dropdown with anything from XOOPS database or similar, I just want a field where a user can select one of 3 options I show them (say a dropdown where you can only choose A, B or C). I guess this is easy but I dont know how to do it...anyone?

thanks

2
phppp
Re: article 1.0 - How to create dropdown
  • 2007/6/8 17:46

  • phppp

  • XOOPS Contributor

  • Posts: 2857

  • Since: 2004/1/25


the file to be modified is /include/form.article.elements.php

3
patagon
Re: article 1.0 - How to create dropdown
  • 2007/6/12 13:48

  • patagon

  • Quite a regular

  • Posts: 235

  • Since: 2002/1/8 0


Thanks, I managed to modify /form.article.elements.php so that I can see a select (I couldnt find any example of dropdown, but a select could work) by doing this:

original:
// Source
$form_element["active"]["art_source"] = new XoopsFormText(art_constant("MD_SOURCE"), "art_source", 50, 255, $art_source);
$form_element["inactive"]["art_source"] = new XoopsFormHidden("art_source", $art_source);

Modified:
// Source - reused as a select
$form_element["active"]["art_source"] = new XoopsFormSelect(art_constant("MD_SOURCE"), "art_source", 50, 3, $art_source);
$form_element["inactive"]["art_source"] = new XoopsFormHidden("art_source", $art_source);

Now, my problem is how do I 'populate' this select with my 3 options? I see places where it does a similar thing, but it pulls the content from somewhere else (or I dont understand it). I would need to define only 3 possible values, say A, B, C.

4
patagon
Re: article 1.0 - How to create dropdown
  • 2007/6/13 3:16

  • patagon

  • Quite a regular

  • Posts: 235

  • Since: 2002/1/8 0


up

5
phppp
Re: article 1.0 - How to create dropdown
  • 2007/6/13 4:09

  • phppp

  • XOOPS Contributor

  • Posts: 2857

  • Since: 2004/1/25


$form_element["active"]["art_source"] = new XoopsFormSelect(art_constant("MD_SOURCE"), "art_source", 50, 3, $art_source);
$form_element["active"]["art_source"]->addOptionArray(
array(
"op1" => "option 1",
"op2" => "option 2",
"op3" => "option 3"
)
);

6
patagon
Re: article 1.0 - How to create dropdown
  • 2007/6/13 15:22

  • patagon

  • Quite a regular

  • Posts: 235

  • Since: 2002/1/8 0


Thanks, this almost works, but:

whenever someone enters the data for the first time it works, showing the option. if you go to edit the entry and change the value in the select, it then shows 'array' (instead of the chosen option' in that field).

7
patagon
Re: article 1.0 - How to create dropdown
  • 2007/6/15 21:38

  • patagon

  • Quite a regular

  • Posts: 235

  • Since: 2002/1/8 0


up

8
patagon
Re: article 1.0 - How to create dropdown
  • 2007/7/8 4:19

  • patagon

  • Quite a regular

  • Posts: 235

  • Since: 2002/1/8 0


I'm bringing this up again because it would solve my other 'article' problem.

to summarize: I managed to create a dropdown based on phpbb advice on this thread. This works when submitting an article, but for whatever the reason whenever I edit the posted article, the option dissapears and is replaced by 'array'...If I could edit and it works as when first submitting that would do it for me...

Login

Who's Online

217 user(s) are online (50 user(s) are browsing Support Forums)


Members: 0


Guests: 217


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Feb 29
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits