Jump to content

chrizz

Members
  • Content Count

    117
  • Joined

  • Last visited

Community Reputation

59 Excellent

About chrizz

  • Rank
    Sr. Member

Profile Information

  • Gender
    Male
  • Location
    Berlin, Germany

Recent Profile Visitors

4,005 profile views
  1. that was exactly what I was looking for. I wasn't aware of the requiredAttr. Works like charm πŸ™‚ Thanks
  2. I am currently experimenting with a form which required specific fields. I want to have front-end (via JS) and backend validation (via PW built-in) but I am struggeling with the "required" attribute. In order to use form.checkValidity(), inputfields need "required='required'" as attribute To make use of the PW validation, the field has to be initialized with $field->required = true; This makes the input field look like this $field = $this->modules->get("InputfieldText"); $field->label = "test"; $field->attr("id+name", "test"); $field->attr("type", "number"); $field->attr("step", "0.001"); $field->attr("placeholder", "placeholder"); $field->attr("required", true); $field->required = 1; $form->add($field); For some reason the results are not the desired ones and I have no clue how this could be solved. The above results in the following output <input id="test" class="required InputfieldMaxWidth" name="test" type="number" maxlength="2048" placeholder="placeholder" step="0.001"> Backend validation will work, but frontend validation fails because of the missing "required" attribute Removing the line $field->required = 1, make it look like this <input id="test" class="InputfieldMaxWidth" name="test" type="number" maxlength="2048" placeholder="placeholder" step="0.001" required="required"> Now the frontend validation works, but the backend validation fails (obviously because the "required" class is missing. Actually I am wondering why the build-in "required" results in a CSS class, rather than in the attribute and why an additional attribute and the class collides. And because I am pretty sure that I am not the first one struggling with this, any hints are much appreciated πŸ™‚ Thanks!
  3. hey guys - thanks again for your valuable input! I think I got just confused by the fact that the same code behaves differently in the last to master versions. Nevertheless, I am going to refactor a bit and take care of my own that an exception is thrown as soon as the page name already exists. thanks again!
  4. that's exactly what I don't want 😞 I guess there's no other way than hooking into these methods (same would apply for page updates (if the name changes as well). Maybe someone knows why/when this chnage has been implemented and/or why I experience differences between the two PW versions.
  5. okay - maybe then it's some weird other co-incidence: Originally I was creating pages via API. Based upon your question I tested the behavior in Admin and guess what: The UI warns me that a page with this name already exists but then adds it's own number at the end. It seems as if PW adds a numbering and checks which first (lowest) number is not already taken yet: A quick research showed that this is wanted behavior. PW takes care of the name automatically. *BUT* How can I avoid this? What I need is a way that duplicates are not created. I want PW do a lot of things, but not in this case πŸ˜‰ The following code behaves differently based on the PW version. $title = "mytitle"; $channel = new Page(); $channel->template = "basic-page"; $channel->parent = $pages->get("/styleguide/"); $channel->title = $title; $channel->name = $this->sanitizer->pageName($title); $channel->save(); with PW 3.0.123 it runs once - a second run results in an SQL exception: Error: Exception: SQLSTATE[23000]: Integrity constraint violation: with PW3.0.148 the code runs as often as you want and generates page names on it's own. So... bug or feature? ^^
  6. I recently upgraded one of my projects to 3.0.148 and I got screwed by the new "unique" flag for pages introdueced here. Until now I was relying on PW's internal logic to throw an exception if a page with the same name already exists using the same parent page. Now I am trying to find a clever and easy to use method which can bring back that functionality. Is there maybe a config option I am not aware of? Because I need this duplicate check in many places of the project I want to find a solution which reduces code duplication. So, is there by chance a config for this? If not: ideas are welcome how this could be solved :) Cheers! chrizz
  7. as discussed yesterday this wasn't the last Wireabend-Bier (perfect wording @marcus!) in Berlin. I am looking forward to meet more of you in the future with another beer πŸ™‚
  8. what about the others Berliners here: @blickwerker, @Bron, @ceberlin, @Dave Damage, @dlen, @fermion, @Jan Fromm, @masslevel, @Mitko, @neophron, @Neue Rituale, @Nico Knoll, @operat, @ottogal, @owzim, @Philipp Nowinski, @RSA, @sisterlarao, @skovar, @skries πŸ™‚
  9. @marcus, is Monday still the plan for the meetup? Looks as if we are the only ones for now though, or do you know from others planning to join us?
  10. @marcus, yep. that works and I'd available for beers πŸ™‚
  11. haha. obviously.... the wrong question... yes πŸ€¦β€β™‚οΈ Thanks a lot for pointing me into the right direction
  12. @bernhard, thats what I did as well - but then I ran into trouble because I needed to access the same class from a different module (autoloaded as well). And then it became tricky because I don't know any way to control the order of autoloading πŸ˜‰
  13. I have a module (autoload: true) which uses a custom class. If it would be only relevant for templates, _init.php would be the way to go but due to autoload functionality I need the class also to be availabel in the backend - this is where _init.php stops working. If the class is declared in config.php it works fine - but is this the recommended way or is there a better solution for this?
  14. I am running into the same issue. Unfortunately I wasn't able to reproduce it isolated, but it happens constantly in my current setup during debugging. Has this issue been solved for you @FrancisChung or is it still happening for you as well?
  15. thanks for bringing this up. To me this means: a cronjob will always use the first defined host, as there's no $_SERVER variable available, aye? Unless for sure the cronjob is called via http (e.g. "curl https:host.../") Thanks for your feedback - helps a lot πŸ™‚
Γ—
Γ—
  • Create New...