Ticket #153 (closed enhancement: fixed)

Opened 8 years ago

Last modified 8 years ago

Add convertElementTo()

Reported by: schst Owned by: sfuchs
Priority: normal Milestone: v0.9.0 stable
Component: patForms Version: current-cvs
Severity: normal Keywords:
Cc:

Description

Add a new method, that enables you to convert an element to a different type, e.g. converting a Enum to a Set.

Change History

comment:1 Changed 8 years ago by schst

See here for the initial request:

http://forum.php-tools.net/index.php?t=msg&th=462

comment:2 Changed 8 years ago by sfuchs

How should this be implemented?

I could think of a static method patForms_Element::convertElement($element, $type), that

  • simply creates a new element using the new type,
  • sets all attributes and properties from the old to the new element and
  • returns the new one

Does that make sense?

comment:3 Changed 8 years ago by schst

Would be nice to be able to call it on a form:

$form->addElement("foo", $aEnum);
$form->convertElement("foo", "Set");

Nevertheless, a static method would be nice to have as well.

comment:4 Changed 8 years ago by sfuchs

  • Owner changed from argh@… to sfuchs

This is now implemented in [265].

However #172 needs to be implemented to convert an Element_Enum to Element_Set without loosing the value.

Please also have a look at the unit test source:trunk/tests/element/Convert.php ... most likely there are some special cases that I've missed.

comment:5 Changed 8 years ago by sfuchs

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.