File upload file in HTMLForm with ooui

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

File upload file in HTMLForm with ooui

Toni Hermoso Pulido-3
Hello,

I'm trying to migrate a HTMLForm to use ooui

by following https://www.mediawiki.org/wiki/OOUI/Using_OOUI_in_MediaWiki

htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, 'myform' );

I noticed that a file upload form field that I had defined is not
rendered correctly when using ooui.

             'fileupload' => array(
                 'section' => 'upload',
                 'label' => 'Upload file',
                 'class' => 'HTMLTextField',
                 'type' => 'file'
             ),

This is shown as a text field but not as a file upload, as I would have
expected...


Is there any way to handle this and using OOUI at the same time?

Thanks!


_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: File upload file in HTMLForm with ooui

Brian Wolff
Im not sure, but having the class specified as HTMLTextField looks wrong
(type & class are mutually exclusive. You should only specify one).

--
Brian

On Sunday, April 15, 2018, Toni Hermoso Pulido <[hidden email]> wrote:
> Hello,
>
> I'm trying to migrate a HTMLForm to use ooui
>
> by following https://www.mediawiki.org/wiki/OOUI/Using_OOUI_in_MediaWiki
>
> htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, 'myform' );
>
> I noticed that a file upload form field that I had defined is not
rendered correctly when using ooui.
>
>             'fileupload' => array(
>                 'section' => 'upload',
>                 'label' => 'Upload file',
>                 'class' => 'HTMLTextField',
>                 'type' => 'file'
>             ),
>
> This is shown as a text field but not as a file upload, as I would have
expected...

>
>
> Is there any way to handle this and using OOUI at the same time?
>
> Thanks!
>
>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: File upload file in HTMLForm with ooui

Toni Hermoso Pulido-3
Hi Brian,

if I only specify one I get this exception:

...

Descriptor with no class for fileupload: Array
(
[section] => upload
[label] => Upload file
[type] => file
[class] =>
)

...

Not using ooui, both are needed and it works...


On 15/04/2018 19:40, Brian Wolff wrote:

> Im not sure, but having the class specified as HTMLTextField looks wrong
> (type & class are mutually exclusive. You should only specify one).
>
> --
> Brian
>
> On Sunday, April 15, 2018, Toni Hermoso Pulido <[hidden email]> wrote:
>> Hello,
>>
>> I'm trying to migrate a HTMLForm to use ooui
>>
>> by following https://www.mediawiki.org/wiki/OOUI/Using_OOUI_in_MediaWiki
>>
>> htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, 'myform' );
>>
>> I noticed that a file upload form field that I had defined is not
> rendered correctly when using ooui.
>>              'fileupload' => array(
>>                  'section' => 'upload',
>>                  'label' => 'Upload file',
>>                  'class' => 'HTMLTextField',
>>                  'type' => 'file'
>>              ),
>>
>> This is shown as a text field but not as a file upload, as I would have
> expected...
>>
>> Is there any way to handle this and using OOUI at the same time?
>>
>> Thanks!
>>
>>
>> _______________________________________________
>> Wikitech-l mailing list
>> [hidden email]
>> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l


_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: File upload file in HTMLForm with ooui

Brian Wolff
Ok, I looked into this a little closer.

type => file is missing from HTMLForm::typeMapping. But class overrides
this, and the HTMLTextField has some code where the type parameter is just
stuck into the html type attribute so it can be used in multiple places.

But in the OOUI case OOUI\TextInputWidget::getSaneType doesnt allow file
types (since ooui probably doesnt support it), so type goes back to text.
Thus breaking this.

So basically no, its not possible currently without implementing your own
HTMLFormField subclass. The fact it worked in the old system may have been
accidental, im not sure. There is probably a bug here somewhere though,
either the two modes should be consistent in their support for file types
or it should fallback to non-ooui in that case (imho)

Sorry,
Brian

On Sunday, April 15, 2018, Toni Hermoso Pulido <[hidden email]> wrote:

> Hi Brian,
>
> if I only specify one I get this exception:
>
> ...
>
> Descriptor with no class for fileupload: Array
> (
> [section] => upload
> [label] => Upload file
> [type] => file
> [class] =>
> )
>
> ...
>
> Not using ooui, both are needed and it works...
>
>
> On 15/04/2018 19:40, Brian Wolff wrote:
>>
>> Im not sure, but having the class specified as HTMLTextField looks wrong
>> (type & class are mutually exclusive. You should only specify one).
>>
>> --
>> Brian
>>
>> On Sunday, April 15, 2018, Toni Hermoso Pulido <[hidden email]> wrote:
>>>
>>> Hello,
>>>
>>> I'm trying to migrate a HTMLForm to use ooui
>>>
>>> by following https://www.mediawiki.org/wiki/OOUI/Using_OOUI_in_MediaWiki
>>>
>>> htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, 'myform' );
>>>
>>> I noticed that a file upload form field that I had defined is not
>>
>> rendered correctly when using ooui.
>>>
>>>              'fileupload' => array(
>>>                  'section' => 'upload',
>>>                  'label' => 'Upload file',
>>>                  'class' => 'HTMLTextField',
>>>                  'type' => 'file'
>>>              ),
>>>
>>> This is shown as a text field but not as a file upload, as I would have
>>
>> expected...
>>>
>>> Is there any way to handle this and using OOUI at the same time?
>>>
>>> Thanks!
>>>
>>>
>>> _______________________________________________
>>> Wikitech-l mailing list
>>> [hidden email]
>>> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>>
>> _______________________________________________
>> Wikitech-l mailing list
>> [hidden email]
>> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: File upload file in HTMLForm with ooui

Gergo Tisza
On Mon, Apr 16, 2018 at 12:40 AM, Brian Wolff <[hidden email]> wrote:

> So basically no, its not possible currently without implementing your own
> HTMLFormField subclass.


The task for that is https://phabricator.wikimedia.org/T170263
Should be pretty easy, the OOUI widget exists already.
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: File upload file in HTMLForm with ooui

Toni Hermoso Pulido-3
El 04/16/2018 a les 05:14 PM, Gergo Tisza ha escrit:

> On Mon, Apr 16, 2018 at 12:40 AM, Brian Wolff <[hidden email]> wrote:
>
>> So basically no, its not possible currently without implementing your own
>> HTMLFormField subclass.
>
> The task for that is https://phabricator.wikimedia.org/T170263
> Should be pretty easy, the OOUI widget exists already.
>

Thank you both for do some research about and also pointing this task!

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l