Jump to content

Clarity

Members
  • Posts

    125
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Clarity

  1. Hello everyone!

    Can you please say how is this situation really possible?

    1) On some line of the code inside a class, I assign the value: $this->var = $this->foo().

    2) On the next line of this code, I compare these two and output to TracyDebugger: bd($this->var == $this->foo());, but it outputs false value (first is null and $this->foo() is a set of pages).

  2. The reason why I was trying to resize SVG is that I need to make repeated set of images sizes of which are independent of sizes which user loads into the field.

    Anyways, adding width and height attributes resolved my problem. Thank you for the advice!

  3. Hello everyone!

    I'm trying to resize SVG image using size() function. However, the image appears to be unchanged. I'm using FileValidatorSvgSanitizer module for sanitization of SVGs. What should I do for resizing SVG image if I want to resize them programmatically?

  4. Thanks for the advice, but it doesn't work for me. The error remains the same. My settings/settings.php is like that:

    <?php
     
    $inputfields = array(
        array(
            "name" => "emails",
            "label" => "Emails",
            "type" => "InputfieldMultiplier",
            "fieldtypeClass" => "FieldtypeText",
            "schemaClass" => "FieldtypeText",
            "qtyMin" => 3,
            "qtyMax" => 6,
            "width" => "100",
            "description" => "",
            "collapsed" => 0,
            "placeholder" => "",
            "columnWidth" => 50
        ),
        array(
            "name" => "phones",
            "label" => "Phones",
            "type" => "InputfieldMultiplier",
            "fieldtypeClass" => "FieldtypeText",
            "schemaClass" => "FieldtypeText",
            "qtyMin" => 3,
            "qtyMax" => 6,
            "width" => "100",
            "description" => "",
            "collapsed" => 0,
            "placeholder" => "",
            "columnWidth" => 50
        )
    );
     
    return $inputfields;
     
    Can you please say what I'm doing wrong?
  5. Hello, @Mats!

    There is a problem with usage of this field when it is being added inside Repeater. The map does not load when I click to Repeater item since Leaflet's JavaScript is not being initialized after AJAX request. Can you please fix it?

    • Like 1
  6. Hello everyone!

    I have an error "Uncaught ReferenceError: jsMarkupLeafletMap is not defined". My version of ProcessWire is 3.0.199 dev and the version of the module is the latest dev. I found that previously @Marco Angeli resolved the problem here, but it doesn't seem to be my case.

    Edit: I forgot to add <?php echo $map->getLeafletMapHeaderLines(); ?> to the head. That was my mistake.

  7. On 5/20/2022 at 10:38 PM, kongondo said:

    Hello @Clarity,

    The menu name is automatically created from the menu title. It is not separately editable via Menu Builder (it's a page though). Could you please explain why you need access to the name?

    The problem is that I need to use the title, say, 'footer-menu' in code: $menuBuilder->getMenuItems('footer-menu'). Then I think it is not a good practice to give a title to menu like 'Footer Menu'. Also, if the title can be multi-language, it might, I think, cause other issues.

  8. Thank you! Finally, I found the root of the problem. I didn't add "return $inputfields;" to the end of file.
     
    I'm not using a namespace explicitly. ProcessWire version is 3.0.199 dev, and everything works fine now.
    • Like 1
  9. Finally, I found a solution: as @MarkE wrote, I was trying to hook not in proper place. I've hooked another ___processInput method, in InputfieldForm. The working hook is:

    wire()->addHookBefore('InputfieldForm::processInput', function($event) {
    	$input = $event->arguments('input');
    	if(!$input->title) {
    		$input->title = '1';
    	}
    	if(!$input->_pw_page_name) {
    		$input->_pw_page_name = '1';
    	}
    });

    Thank you all for the advices!

    • Like 3
  10. I found that my initial idea of modifying the page is not good.

    By looking closer into processInput method and exploring what exactly raises the error, I found that the following code does it:

        /** @var InputfieldPageName $nameField */
        $nameField = $form->getChildByName('_pw_page_name');     
        $name = $nameField->value; 
    
        if(!strlen($name)) {
            $nameField->error($this->_("Missing required field: name")); 
            return false; 
        }


    So the error raises before actual operation with page. I've tried to modify the value of $name via the hook (write "1" to it just to check if it works):

        wire()->addHookBefore('ProcessPageAdd::processInput', function($event) {
            $form = $event->arguments('form');
            $form->getChildByName('_pw_page_name')->attr('value', '1');
            $event->arguments('form', $form);
        });

    Inside the hook the value changes, however, the error still appears. Bar dump of $name inside the code of processInput shows that $name still has zero length. Can you please explain what's wrong and why I can't modify getChildByName()'s value in a hook?

×
×
  • Create New...