On Wed, 2006-12-13 at 18:40 +0100, Philippe Marschall wrote:
2006/12/13, Norbert Hartl <norbert(a)hartl.name>me>:
Hi,
I'm playing with custom views in Magritte. I have a model
and overwrote descriptionContainer with my own instance of
MAComponentRenderer.
What I'm trying to achieve is to display a text input the
following:
<label for="anyid">labeltext</label>
<input type="text" id="anyid"..../>
As a quick test I changed the renderLabel: to
renderLabel: aDescription
aDescription hasLabel
ifTrue: [ html
label attributeAt: 'for' put: aDescription hash;
with: [ html render: aDescription label ] ]
I need an id attribute in the <input> tag which has the
same content as the for attribute in the <label> tag.
I don't have a glue how to insert an id attribute to the
renderControl:. Is there a way to add an attribute if I only
have a component. I doubt the component description is the
right place to put.
If I only want to change the behaviour of the text input field,
is it best to overwrite the visitStringDescription?
thanks in advance,
This is something that crossed my mind too. To get an id you can use
something like this:
(component childAt: aDescription) ajaxId
Now for the rendering of input tags. I see no way other than changing
or subclassing all the renderer classes.
MAMultiselectListComponent
MASelectListComponent
MATextInputComponent
MATextAreaComponent
MARadioGroupComponent
MARangeComponent
MATextPasswordComponent
MAFileUploadComponent
and whatever I forgot
Honestly I think changing is better because I think it makes sense to
have this as default behavior.
Ok, I changed it for me unless there is a better solution.
(I myself need some more time to get in touch with Magritte)
I did:
MAElementComponent>>attributes
attributes ifNil: [
attributes := self description attributes copy.
].
^ attributes
MAElementComponent>>attributesAt: aKey put: aValue
self attributes at: aKey put: aValue
I don't know if it is an error if the component is not aware
about changes in the description attributes.
regards,
Norbert