bernhard Posted March 22, 2020 Share Posted March 22, 2020 The title might sound more exciting that it actually is. It's just a little helper module to keep things organized ? Basically it just saves you from finding the correct require_once("where/is/my/nette?") and, for a little extra security, it adds an .htaccess file to block all direct access to Nette source files. Why? Nette is an awesome framework with some awesome features/utilities that ProcessWire lacks. Creating separate modules and including Nette packages multiple times in those modules would not be efficient. RockNette makes it easy to store them in a central place. Usage You'll get all necessary instructions on the module information screen: https://github.com/BernhardBaumrock/RockNette 8 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted March 24, 2020 Share Posted March 24, 2020 The links seem to be broken @bernhard. By the way, could you share your experience using nette forms. I did try to incorporate them, but never actually finished(( Link to comment Share on other sites More sharing options...
bernhard Posted March 24, 2020 Author Share Posted March 24, 2020 Hi @Ivan Gretsky Which links are broken? Hm... Nette Forms... I really like one thing: Synched frontend + backend form validation. But on the other hand I really miss one thing: ProcessWire ? Especially hooks. In Nette there's nothing like hooks as far as I know. They do everything by extending base classes. This can be great for more complex modifications (that's why we now have the new Page classes in ProcessWire), but modifying just one single Inputfield of a Nette form was hard to impossible for me when I played around with it some time (years?) ago... That experience might be a little different know that I made quite some progress in OOP. One thing I could also not get working was CSRF protection via Nette. So I implemented it using ProcessWire's internal feature: Yes... it's obviously been 2 years since I worked on that ? I need some forms on a new project, so I might have a look into a new Forms Module using the new RockNette concept and Nette v3.0 1 Link to comment Share on other sites More sharing options...
eydun Posted April 28, 2020 Share Posted April 28, 2020 Thank you for this module. Nette is an awesome framework with some awesome features/utilities that ProcessWire lacks. May I ask, which Nette components you prefer to use above ProcessWire? Link to comment Share on other sites More sharing options...
bernhard Posted April 28, 2020 Author Share Posted April 28, 2020 Some Examples: 1) I've used Tokenizer to render search results: 2) I'm using the nette mailer for perfect e-mail scores using DKIM: 3) I've used Nette Forms for custom Form implementations with Backend + Frontend validation 4) I've used some of the image manipulation functions: https://doc.nette.org/en/3.0/images 4 Link to comment Share on other sites More sharing options...
eydun Posted September 30, 2020 Share Posted September 30, 2020 Hi @bernhard. I am just trying to learn ? What is the reason that you place the "Nette"-components in the "/assets"-folder, and not in the "modules/RockNette"-folder? Link to comment Share on other sites More sharing options...
bernhard Posted September 30, 2020 Author Share Posted September 30, 2020 Hi eydun, I thought it might make sense to be able to share the nette components across several modules. I'm not sure if that is the best approach. Another option would be to use composer in the root folder to load nette components (I think that would be the more standard way)! I just didn't want to put it in the module itself because this would mean I'd need to update the modules with every update of nette... 3 Link to comment Share on other sites More sharing options...
kalimati Posted November 28, 2020 Share Posted November 28, 2020 HI Bernhard, Thanks for the module. Looks interesting and worth exploring. I am trying it out but running into a problem while using a rendering function for UIkit, adapted from the makeBootstrap4 one used on the Nette site as an example. I get the error: Call to undefined function makeUIkit(). Any idea where I may be going wrong. Thanks. namespace ProcessWire; use Nette\Forms\Form; function makeUIkit(Form $form): void { $renderer = $form->getRenderer(); $renderer->wrappers['controls']['container'] = null; $renderer->wrappers['pair']['container'] = 'div class="uk-margin"'; $renderer->wrappers['pair']['.error'] = 'uk-form-danger'; $renderer->wrappers['control']['container'] = 'div class="uk-width-2-3@s uk-form-controls"'; $renderer->wrappers['label']['container'] = 'div class="uk-width-1-3@s uk-form-label"'; $renderer->wrappers['control']['description'] = 'span class="form-text"'; // non uikit $renderer->wrappers['control']['errorcontainer'] = 'span class="form-control-feedback"'; // non uikit $renderer->wrappers['control']['.error'] = 'is-invalid'; // non uikit foreach ($form->getControls() as $control) { $type = $control->getOption('type'); if ($type === 'button') { $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'uk-button uk-button-primary' : 'uk-button uk-button-secondary'); $usedPrimary = true; } elseif ($type === 'text') { $control->getControlPrototype()->addClass('uk-input'); } elseif ($type === 'textarea') { $control->getControlPrototype()->addClass('uk-textarea'); } elseif ($type === 'select') { $control->getControlPrototype()->addClass('uk-select'); } elseif ($type === 'file') { $control->getControlPrototype()->addClass('uk-input'); } elseif (in_array($type, ['checkbox', 'radio'], true)) { if ($control instanceof Nette\Forms\Controls\Checkbox) { $control->getLabelPrototype()->addClass('uk-checkbox'); } else { $control->getItemLabelPrototype()->addClass('uk-radio'); } $control->getControlPrototype()->addClass('form-check-input'); $control->getSeparatorPrototype()->setName('div')->addClass('form-check'); } } } $states = [ 'Andaman & Nicobar Islands' => 'Andaman & Nicobar Islands', 'Andhra Pradesh' => 'Andhra Pradesh', 'Arunachal Pradesh' => 'Arunachal Pradesh', 'Assam' => 'Assam', 'Bihar' => 'Bihar', 'Chandigarh' => 'Chandigarh', 'Chhattisgarh' => 'Chhattisgarh', 'Dadra-Nagar Haveli & Daman-Diu' => 'Dadra-Nagar Haveli & Daman-Diu', 'Delhi' => 'Delhi', 'Goa' => 'Goa', 'Gujarat' => 'Gujarat', 'Haryana' => 'Haryana', 'Himachal Pradesh' => 'Himachal Pradesh', 'Jammu and Kashmir' => 'Jammu and Kashmir', 'Jharkhand' => 'Jharkhand', 'Karnataka' => 'Karnataka', 'Kerala' => 'Kerala', 'Ladakh' => 'Ladakh', 'Lakshadweep' => 'Lakshadweep', 'Madhya Pradesh' => 'Madhya Pradesh', 'Maharashtra' => 'Maharashtra', 'Manipur' => 'Manipur', 'Meghalaya' => 'Meghalaya', 'Mizoram' => 'Mizoram', 'Nagaland' => 'Nagaland', 'Odisha' => 'Odisha', 'Puducherry' => 'Puducherry', 'Punjab' => 'Punjab', 'Rajasthan' => 'Rajasthan', 'Sikkim' => 'Sikkim', 'Tamil Nadu' => 'Tamil Nadu', 'Telangana' => 'Telangana', 'Tripura' => 'Tripura', 'Uttar Pradesh' => 'Uttar Pradesh', 'Uttarakhand' => 'Uttarakhand', 'West Bengal' => 'West Bengal' ]; $form = new Form; $form->onRender[] = 'makeUIkit'; $form->addText('name', 'Name:') ->setRequired('Please fill your %label.'); $form->addEmail('email', 'Email:') ->setRequired('Please fill your %label.'); $form->addText('designation', 'Designation:') ->setRequired() ->setHtmlAttribute('class', 'uk-width-1-2@s'); $form->addText('company', 'Company:') ->setRequired() ->setHtmlAttribute('class', 'uk-width-1-2@s'); $form->addCheckbox('printed', 'Please send me the printed edition. Delivered within India only.'); $form->addText('address', 'Address:') ->setHtmlAttribute('class', 'uk-width-1-2@s') ->addConditionOn($form['printed'], $form::EQUAL, true); $form->addText('city', 'City:') ->setHtmlAttribute('class', 'uk-width-1-2@s') ->addConditionOn($form['printed'], $form::EQUAL, true); $form->addSelect('state', 'State:', $states) ->setHtmlAttribute('class', 'uk-width-1-2@s') ->addConditionOn($form['printed'], $form::EQUAL, true); $form->addInteger('pin', 'PIN:') ->setHtmlAttribute('class', 'uk-width-1-2@s') ->addConditionOn($form['printed'], $form::EQUAL, true) ->addRule($form::PATTERN, 'Please enter a valid Indian PIN code', '^[1-9]{1}[0-9]{5}$'); $form->addSubmit('subscribe', 'Subscribe'); ?> <script pw-append="html-head" src="https://nette.github.io/resources/js/3/netteForms.min.js"></script> <div id='content' class='uk-width-expand'> <div class="uk-child-width-1-2@m" uk-grid> <div> <?php $latest_mag = $pages->get("template=mag-issue, sort=-created"); echo "<img class='uk-align-center' src='{$latest_mag->images->first->url}' alt='{$latest_mag->title}' />"; ?> </div> <div> <h2>Subscribe!</h2> <?php $form->render() ?> </div> </div> </div> Link to comment Share on other sites More sharing options...
kalimati Posted November 28, 2020 Share Posted November 28, 2020 It is a namespace issue. Changed the reference to makeUIkit to: $form->onRender[] = 'processwire/makeUIkit'; 1 Link to comment Share on other sites More sharing options...
kalimati Posted January 20, 2021 Share Posted January 20, 2021 Hi bernhard, Can you provide a sample code for multiple forms on one page with independent error reporting and success messaging? Thanks Link to comment Share on other sites More sharing options...
bernhard Posted January 20, 2021 Author Share Posted January 20, 2021 Hi @kalimati I don't have one at hand and have lots of client work to do. If your request is important I'm happy to help and you can request a quote via PM ? I'm also working on another forms project right now, so it might be interesting to hear your needs and discuss options... Link to comment Share on other sites More sharing options...
kalimati Posted January 20, 2021 Share Posted January 20, 2021 Thanks for your prompt response. Nothing urgent. Will try and figure it out. 1 Link to comment Share on other sites More sharing options...
bernhard Posted January 20, 2021 Author Share Posted January 20, 2021 Would be nice to get some examples that I can add to the readme if you come up with a working solution ? Link to comment Share on other sites More sharing options...
kalimati Posted January 20, 2021 Share Posted January 20, 2021 Sure. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now