File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,7 @@ class BigModel(BaseModel):
144
144
None , description = 'This field is not required, it must start with a capital letter if provided'
145
145
)
146
146
info : Annotated [str | None , Textarea (rows = 5 )] = Field (None , description = 'Optional free text information about you.' )
147
+ repo : str = Field (json_schema_extra = {'placeholder' : '{org}/{repo}' }, title = 'GitHub repository' )
147
148
profile_pic : Annotated [UploadFile , FormFile (accept = 'image/*' , max_size = 16_000 )] = Field (
148
149
description = 'Upload a profile picture, must not be more than 16kb'
149
150
)
Original file line number Diff line number Diff line change @@ -197,6 +197,7 @@ def json_schema_field_to_field(
197
197
initial = schema .get ('default' ),
198
198
autocomplete = schema .get ('autocomplete' ),
199
199
description = schema .get ('description' ),
200
+ placeholder = schema .get ('placeholder' ),
200
201
)
201
202
202
203
Original file line number Diff line number Diff line change @@ -522,3 +522,28 @@ def test_form_description_leakage():
522
522
'submitUrl' : '/foobar/' ,
523
523
'type' : 'ModelForm' ,
524
524
}
525
+
526
+
527
+ class RichForm (BaseModel ):
528
+ repo : str = Field (json_schema_extra = {'placeholder' : '{org}/{repo}' }, title = 'GitHub repository' )
529
+
530
+
531
+ def test_form_fields ():
532
+ m = components .ModelForm (model = RichForm , submit_url = '/foobar/' )
533
+
534
+ assert m .model_dump (by_alias = True , exclude_none = True ) == {
535
+ 'formFields' : [
536
+ {
537
+ 'htmlType' : 'text' ,
538
+ 'locked' : False ,
539
+ 'name' : 'repo' ,
540
+ 'placeholder' : '{org}/{repo}' ,
541
+ 'required' : True ,
542
+ 'title' : ['GitHub repository' ],
543
+ 'type' : 'FormFieldInput' ,
544
+ }
545
+ ],
546
+ 'method' : 'POST' ,
547
+ 'submitUrl' : '/foobar/' ,
548
+ 'type' : 'ModelForm' ,
549
+ }
You can’t perform that action at this time.
0 commit comments