def __call__(self): self.buttons = ( 'save', Button(name='regenerate_api_key', title='Regenerate API key'), Button(name='upgrade_subscription', css_class='hidden'), ) if self.request.user.unsubscribed: subscribe_button = Button(name='subscribe_to_newsletter', title='Subscribe to newsletter') self.buttons = self.buttons + (subscribe_button, ) return super(SettingsForm, self).__call__()
def __call__(self, request): self.request = request self.wizard_state = self.wizard_state_class(request, self.wizard.name) step = self.wizard_state.get_step_num() if step > len(self.wizard.schemas)-1: states = self.wizard_state.get_step_states() result = self.wizard.done(request, states) self.wizard_state.clear() return result form_view = self.form_view_class(request) schema = self.wizard.schemas[step] self.schema = schema.bind(request=request) form_view.schema = self.schema buttons = [] prev_disabled = False next_disabled = False if hasattr(schema, 'prev_ok'): prev_disabled = not schema.prev_ok(request) if hasattr(schema, 'next_ok'): next_disabled = not schema.next_ok(request) prev_button = Button(name='previous', title='Previous', disabled=prev_disabled) next_button = Button(name='next', title='Next', disabled=next_disabled) done_button = Button(name='next', title='Done', disabled=next_disabled) if step > 0: buttons.append(prev_button) if step < len(self.wizard.schemas)-1: buttons.append(next_button) else: buttons.append(done_button) form_view.buttons = buttons form_view.next_success = self.next_success form_view.previous_success = self.previous_success form_view.previous_failure = self.previous_failure form_view.show = self.show form_view.appstruct = getattr(schema, 'appstruct', None) result = form_view() return result
def _init_behaviors(self, specific_behaviors): super(FormView, self)._init_behaviors(specific_behaviors) self.buttons = [ Button(title=getattr(behavior, 'submission_title', behavior.title), name=behavior.title) for behavior in self.behaviors_instances.values() ]
def _form(self, schema=None, **kwargs): self._schema = (schema or self._base_schema).bind( request=self._request, dbsession=self._request.dbsession) form = Form(self._schema, buttons=[Button(name='formsubmit', title=_('Submit'))], **kwargs) return form
def _form(self, **kwargs): self._schema = self._base_schema.bind( request=self._request, dbsession=self._request.dbsession) buttons = [Button(name='formsubmit', title=_('Submit'))] form = Form( self._schema, buttons=buttons, **kwargs ) return form
def _get_form(geo_form_schema, template, request, with_captcha=False): renderer = _get_renderer(geo_form_schema.templates_user) schema = geo_form_schema.schema_user if with_captcha: schema = _add_captcha(geo_form_schema, schema) form_action = request.route_url('form', schema=geo_form_schema.name) submit_button = Button(name='formsubmit', title=_('Submit')) form = Form( schema, buttons=(submit_button,), renderer=renderer, action=form_action) _set_form_widget(form, geo_form_schema.schema_user, template) _populate_widgets(form.schema, DBSession, request) return form
def _makeOne(self, **kw): from deform.form import Button return Button(**kw)