1
deka87
How do I put two dropdowns in one line in the Edit Profile form?
  • 2010/4/29 14:03

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


Hi guys,

Is it possible to put two custom dropdowns in one line in the Edit Profile form like this:

Resized Image


instead of having them like this:

Resized Image


thanks in advance
Mind anchors

2
iHackCode
Re: How do I put two dropdowns in one line in the Edit Profile form?

did you try making a custom xoopsformelement object?
CBB / LatestNews / Publisher / XM-Spotlight

(ノ◕ヮ◕)ノ*:・゚✧

3
deka87
Re: How do I put two dropdowns in one line in the Edit Profile form?
  • 2010/5/13 21:17

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


thanks for your reply Bandit-X! i'd be cool if you explained how or at least where to do this cos unfortunately im not a coder. i have an idea of making a xoopsform element and i've tried it once but im not sure where to start when working on an edit user profile form.
Mind anchors

4
iHackCode
Re: How do I put two dropdowns in one line in the Edit Profile form?

lets say i made this class.

class/xoopsform/formdualselect.php
le="color: #000000"><?php class XoopsFormDualSelect extends XoopsFormElement { var $_first; var $_second; function XoopsFormDualSelect($caption, $firstObj, $secondObj) { $this->_first = $firstObj; $this->_second = $secondObj; $this->setCaption($caption); } /** * Prepare HTML for output * * @return string HTML */ function render() { $ele_name = $this->_first->getName(); $ele_title = $this->_first->getTitle(); $ele_value = $this->_first->getValue(); $ele_options = $this->_first->getOptions(); $ret = '<select size="' . $this->_first->getSize() . '"' . $this->_first->getExtra(); if ($this->_first->isMultiple() != false) { $ret .= ' name="' . $ele_name . '[]" id="' . $ele_name . '" title="'. $ele_title. '" multiple="multiple">' ; } else { $ret .= ' name="' . $ele_name . '" id="' . $ele_name . '" title="'. $ele_title. '">' ; } foreach($ele_options as $value => $name) { $ret .= '<option value="' . htmlspecialchars($value, ENT_QUOTES) . '"'; if (count($ele_value) > 0 && in_array($value, $ele_value)) { $ret .= ' selected="selected"'; } $ret .= '>' . $name . '</option>' ; } $ret .= '</select>'; $ele_name = $this->_second->getName(); $ele_title = $this->_second->getTitle(); $ele_value = $this->_second->getValue(); $ele_options = $this->_second->getOptions(); $ret .= ' <select size="' . $this->_second->getSize() . '"' . $this->_second->getExtra(); if ($this->_second->isMultiple() != false) { $ret .= ' name="' . $ele_name . '[]" id="' . $ele_name . '" title="'. $ele_title. '" multiple="multiple">' ; } else { $ret .= ' name="' . $ele_name . '" id="' . $ele_name . '" title="'. $ele_title. '">' ; } foreach($ele_options as $value => $name) { $ret .= '<option value="' . htmlspecialchars($value, ENT_QUOTES) . '"'; if (count($ele_value) > 0 && in_array($value, $ele_value)) { $ret .= ' selected="selected"'; } $ret .= '>' . $name . '</option>' ; } $ret .= '</select>'; return $ret; } /** * @seealso XoopsForm::renderValidationJS */ function renderValidationJS() { //not finished. return ''; } }


i could use.
le="color: #000000"><?php //load class file include_once $GLOBALS['xoops']->path('class/xoopsform/formdualselect.php'); $dualDrop = new XoopsFormDualSelect('Something Cool',$umode_select,$uorder_select); //adding two xoopsselect obj to the element $form->addElement($dualDrop); //adding to the form


the above code is not tested well. (made it in like 10 minutes, but works). hopefully someone can build on it.
CBB / LatestNews / Publisher / XM-Spotlight

(ノ◕ヮ◕)ノ*:・゚✧

5
Danielw42
Re: How do I put two dropdowns in one line in the Edit Profile form?
  • 2010/5/16 6:19

  • Danielw42

  • Just popping in

  • Posts: 15

  • Since: 2010/1/14


Hi Bandit-x
Could you explain more precisely?

6
ghia
Re: How do I put two dropdowns in one line in the Edit Profile form?
  • 2010/5/16 10:57

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


What do you not understand?
First block is a file to put in the class directory.
Second is example of how to use in form, where $umode_select,$uorder_select two formselects are, created and parmeterized before (code for that is not shown).

7
Danielw42
Re: How do I put two dropdowns in one line in the Edit Profile form?
  • 2010/5/16 16:18

  • Danielw42

  • Just popping in

  • Posts: 15

  • Since: 2010/1/14


Ghia, thank you for your response.
I still don't understand the second part.
I want to put two or three dropdowns in one line in both edit profile and register form.

Where do I have to put this code to make it work?
le="color: #000000"><?php include_once $GLOBALS['xoops']->path('class/xoopsform/formdualselect.php'); $dualDrop = new XoopsFormDualSelect('Something',$test1,$test2); $form->addElement($dualDrop);

8
ghia
Re: How do I put two dropdowns in one line in the Edit Profile form?
  • 2010/5/17 0:55

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


For the profile handling, it will take a lot more then for a custom form. Search for select_multi and XoopsFormSelect in the files of modules profile and system, then insert a similar piece of code for eg select_dual and XoopsFormDualSelect.

Seeing all that, I don't think it will be a good idea ...

9
Catzwolf
Re: How do I put two dropdowns in one line in the Edit Profile form?
  • 2010/5/17 3:00

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Nice form class Bandit, I wa about to do the same myself when I was skimming this post until I saw that you had done it your self.

To make it simpler, I would have used the two select forms class forms and used div for positioning.

10
trabis
Re: How do I put two dropdowns in one line in the Edit Profile form?
  • 2010/5/17 12:55

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Maybe something like this:
<?php xoops_load('XoopsFormElement'); class XoopsFormDualElement extends XoopsFormElement { var $_first; var $_second; function XoopsFormDualElement($caption, $firstObj, $secondObj) { $this->_first = $firstObj; $this->_second = $secondObj; $this->setCaption($caption); } /** * Prepare HTML for output * * @return string HTML */ function render() { xoops_load('XoopsFormLabel'); $ret = new XoopsFormLabel($this->getCaption(), $this->_first->render() . $this->_second->render()); return $ret; } /** * @seealso XoopsForm::renderValidationJS */ function renderValidationJS() { $ret = $this->_first->renderValidationJS() . $this->_second->renderValidationJS()); return $ret; } } ?>


Where first object and second object are instances of a XoopsFormElement. That way we could use more than select boxes.

Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Aug 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!