- return unless (defined $form->field("do") && $form->field("do") eq "create");
-
- for my $field ($form->field) {
- next unless "$field" eq "type";
- if ($field->type eq 'select') {
- # remove po from the types list
- my @types = grep { $_ ne 'po' } $field->options;
- $field->options(\@types) if scalar @types;
- }
- else {
- # make sure the default value is not po;
- # does this case actually happen?
- debug sprintf("po(formbuilder) type field is not select - not implemented yet");
+ return unless defined $form->field("do");
+
+ # Do not allow to create pages of type po: they are automatically created.
+ # The main reason to do so is to bypass the "favor the type of linking page
+ # on page creation" logic, which is unsuitable when a broken link is clicked
+ # on a slave (PO) page.
+ # This cannot be done in the formbuilder_setup hook as the list of types is
+ # computed later.
+ if ($form->field("do") eq "create") {
+ for my $field ($form->field) {
+ next unless "$field" eq "type";
+ if ($field->type eq 'select') {
+ # remove po from the list of types
+ my @types = grep { $_ ne 'po' } $field->options;
+ $field->options(\@types) if scalar @types;
+ }
+ else {
+ # make sure the default value is not po;
+ # does this case actually happen?
+ debug "po(formbuilder) ".gettext("type field is not select - not implemented yet");
+ }